I Can Feel My Grade in the Flying Test Papers
Time limit1sMemory limit256 MB
Split an array into K contiguous groups; maximize the minimum group sum.
- Level
Medium6 of 10
- Topics
- Binary search, Greedy, Dynamic programming, Prefix sum
- Solved
- No attempts yet
Problem
The course 'Database System Algorithms Through Operating Systems', famous for its wide exam scope and hard assignments, has so many test papers that the exam cannot be held indoors, so it is held outside. Hyeonsu, a student in the course, solved every problem that could be solved over a long period of time and had only the submission left. But a sudden strong wind blew all of his test papers away, and he used up all the remaining time picking them up.
Among the rules written on the test papers is one, for the convenience of the grading assistant, that the test papers must be submitted in order. Because of this rule, Hyeonsu is about to have the exam he struggled through scored as 0.
However, Joochan, a kind assistant, decided to give Hyeonsu one chance since he had participated actively in class. Since rules are rules, he cannot give a high score, so he decided to split the test papers into groups keeping the current order, compute the sum of correct answers in each group, and take the minimum of those sums as the exam score. Write a program that computes the maximum score Hyeonsu can get on this exam.
Hyeonsu never solves a problem he does not know, so every problem he solved can be considered correct, and the assistant is kind enough to give the largest score he can.
Input
The first line gives the number of test papers and the number of groups to split them into, as integers. ()
The second line gives the number of correct answers on each test paper, as integers. ()
Output
Print the maximum score Hyeonsu can get.