아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

TOO EASY Cookie Run

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

요약
모든 단계에 더할 음이 아닌 정수 X 중에서, 합이 M 이상인 부분 배열이 K개 이상이 되는 최솟값을 구한다.
난이도

보통10점 중 7점

유형
이분 탐색, 투 포인터, 누적 합
정답자
아직 제출이 없습니다

문제

Cookie Run game is a popular game in which the cookie character runs through a map consisting of N stages to score points. 

Soo Young, the map designer for Cookie Run, was preparing a new map patch for Children's Day. After working hard to create an attractive map and testing it for the last time the day before the patch, she suddenly realized that the map was designed to be too easy!

The map design of the cookie run game consists of the following rules. 

  • Each stage is given a difficulty level of A_0,A_1,A_2,...,A_N−1A\_0, A\_1, A\_2, ..., A\_{N-1}, and the higher the difficulty is, the more difficult it is to pass the corresponding stage.
  • If the sum of the difficulty levels of consecutive stages is greater than or equal to MM, we call this section as interesting section. That is, if A_i+A_i+1+...+A_j≥MA\_i + A\_{i+1} + ... + A\_j \geq M, section (i,j)(i, j) is an interesting section.
  • Maps should always have at least KK interesting section.

In other words, the following conditions should be satisfied:

  • Let TT be the number of pairs (i,j)(i, j) satisfying the following conditions:

    • 0≤i≤j≤N−10 \le i \le j \le N-1
    • A_i+A_i+1+...+A_j≥MA\_{i} + A\_{i+1} + ... + A\_{j} \ge M.
  • Then, T≥KT \ge K for the given integer KK.

To solve this problem, Soo Young requested help from KAIST RUN Spring Contest participants.

Since there is not much time left until the patch release, all Soo Young can do is add difficulty XX to all stages at once to make it more difficult. 

Your job is to find the smallest non-negative integer XX that satisfies these conditions.

입력

The first line contains three space-separated integers, NN, MM, and KK.

The second line contains NN space-separated integers A_0,A_1,⋯ ,A_N−1A\_{0}, A\_{1}, \cdots, A\_{N-1}.

출력

Print a single non-negative integer denoting the smallest possible XX.

You can assume that at least one non-negative integer XX exists, satisfying the given conditions.

제한

  • 1≤N≤100,0001 \le N \le 100\\,000
  • 1≤M≤10181 \le M\le 10^{18}
  • 1≤K≤N(N+1)21 \le K \le \frac{N (N+1)}{2}
  • 0≤A_i≤1090 \le A\_{i} \le 10^9 (0≤i≤N−1)(0 \le i \le N-1)

예제3

  1. 예제 1

    입력
    3 20 5
    4 0 4
    
    예상 출력
    16
    
  2. 예제 2

    입력
    5 30 4
    1 2 3 4 5
    
    예상 출력
    6
    
  3. 예제 3

    입력
    4 32 4
    8 7 5 9
    
    예상 출력
    9