Industry Improvements

면접 대비

시간 제한2초메모리 제한1024 MB

요약
상자들을 주어진 순서대로 최대 k개의 연속한 구간으로 나눌 때, 구간 합의 최댓값을 최소로 만드는 용량을 구한다.
난이도

보통10점 중 5점

유형
이분 탐색, 그리디, 누적 합
정답자
아직 제출이 없습니다

문제

As a member of the Factory Planning Committee, you are responsible for overseeing the production process and ensuring that everything runs smoothly.

The committee aims to guarantee efficient processing of boxes by the machines in the production line without breakdowns. You recognise that a machine is more prone to breaking down when handling heavier objects, and therefore, propose to set a maximum weight capacity for the machines. Considering budget constraints, the committee also agrees to limit the number of times a machine can be started to no more than kk times.

Your task is to determine the minimum weight capacity required for a machine line to process all boxes, while ensuring that the machine line is started no more than kk times and the boxes are processed in the given order.

As an example, consider the first sample input. We can process all boxes by splitting the boxes in these three contiguous subsequences: 7,3,2,3,1,4\\{7\\}, \\{3, 2, 3\\}, \\{1, 4\\} With this split, the capacity of the machine needs to be 88 units of weight.

입력

The input consists of:

  • One line with two integers nn and kk (1≤n≤1051 \leq n \leq 10^5, 1≤k≤1031 \leq k \leq 10^3), the number of boxes and the number of times the machine can be started.
  • One line with nn integers xx (1≤x≤10101 \leq x \leq 10^{10}), the weights of the boxes, in the order in which they need to be processed.

출력

Output the minimum weight capacity required by the machine to process all boxes within kk runs or less.

예제3

  1. 예제 1

    입력
    6 3
    7 3 2 3 1 4
    
    예상 출력
    8
    
  2. 예제 2

    입력
    4 1
    11 18 3 10
    
    예상 출력
    42
    
  3. 예제 3

    입력
    5 3
    123456789 987654321 111111111 555555555 444444444
    
    예상 출력
    1098765432