시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
3 초 | 512 MB | 219 | 72 | 43 | 28.859% |
You have an array w1, w2, . . . , wn of length n.
You need to choose a subsequence of k elements. Let their indices be 1 ≤ i1 < i2 < . . . < ik ≤ n.
Your goal is to find the minimum possible value of
max ((wi1 + wi2),(wi2 + wi3), . . . ,(wik−1 + wik),(wik + wi1))
among all such subsequences.
The first line of input contains two integers n and k: the number of elements in the array w and the length of subsequence (3 ≤ k ≤ n ≤ 200 000).
The second line contains n space-separated integers w1, w2, . . . , wn (1 ≤ wi ≤ 109).
Print one integer: the minimum possible value of
max ((wi1 + wi2),(wi2 + wi3), . . . ,(wik−1 + wik),(wik + wi1))
among all subsequences of length k.
5 3 17 18 17 30 35
35
Camp > Petrozavodsk Programming Camp > Winter 2019 > Day 1: 300iq Contest B번