Best Subsequence
Time limit3sMemory limit512 MB
Pick k elements of an array in index order so that the largest sum of two cyclically adjacent chosen elements is as small as possible.
- Level
Medium7 of 10
- Topics
- Binary search, Greedy, Dynamic programming
- Solved
- No attempts yet
Problem
You are given an array of length .
You need to choose a subsequence of elements. Let their indices be .
Your goal is to find the minimum possible value of
among all such subsequences.
Input
The first line contains two integers and (), the length of the array and the length of the subsequence.
The second line contains space-separated integers ().
Output
Print one integer: the minimum possible value of the expression above over all subsequences of length .