Logo
(追記) (追記ここまで)

26222번 - Maximum sum with swaps 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
6 초 (추가 시간 없음) 1024 MB222100.000%

문제

Given an array of integers $A_i$ of length $N,ドル you are to find an interval within the array, which has maximum sum of the elements in it. However, before choosing the interval, you are allowed to perform no more than $K$ swaps. Each swap makes two elements of the array exchange places.

An interval within the array is an arbitrary set of its consecutive elements.

입력

The first line of the input file contains two integers: $N$ --- the number of elements in the array (1ドル \le N \le 100,000円$), $K$ --- the maximum possible number of swaps (0ドル \le K \le 10$). The second line lists the elements of the array $A_i,ドル one by one. All $A_i$ are integers, no larger than 10ドル^9$ by absolute value. It is guaranteed that there is at least one positive number among $A_i$.

출력

The first line of the output file must contain two integers: $S$ --- the resulting sum of elements in the interval and $M$ --- the number of swaps performed (0ドル \le M \le K$).

The following $M$ lines must describe all swaps in order of their execution. For every $j$-th swap print two integers $u_j$ and $v_j,ドル denoting two positions in the array, whose values are to be swapped (1ドル \le u_j \neq v_j \le N$). The positions in the array are numbered consecutively starting from one.

The last line must contain the interval where the sum must be calculated, described as two integers: $L$ being the index of the leftmost position in the array belonging to the interval, and $R$ being the index of the rightmost position belonging to the interval (1ドル \le L \le R \le N$).

제한

예제 입력 1

3 2
1 2 3

예제 출력 1

6 0
1 3

예제 입력 2

3 3
1 -2 3

예제 출력 2

4 2
1 2
2 3
2 3

예제 입력 3

3 0
1 -2 3

예제 출력 3

3 0
3 3

힌트

출처

Contest > Open Cup > 2016/2017 Season > Stage 2: Grand Prix of Eurasia 1번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /