Subsegments with Large Sums

AtCoder
IDarc168_e
Time2000ms
Memory256MB
Difficulty
You are given a sequence of positive integers $A=(A_1,A_2,\cdots,A_N)$ of length $N$. Consider dividing this sequence into $K$ non-empty contiguous subsequences. Among these $K$ contiguous subsequences, the number of ones whose sum of elements is at least $S$ will be called the **score**. Find the maximum value of the score. ## Constraints * $1 \leq K \leq N \leq 250000$ * $1 \leq A_i \leq 10^9$ * $1 \leq S \leq 10^{15}$ * All input values are integers. ## Input The input is given from Standard Input in the following format: $N$ $K$ $S$ $A_1$ $A_2$ $\cdots$ $A_N$ [samples]
Samples
Input #1
4 3 6
1 4 2 8
Output #1
2

If the sequence is divided into $(1),(4,2),(8)$, the score will be $2$. No higher score can be achieved, so the answer is $2$.
Input #2
10 5 2
1 1 1 1 1 1 1 1 1 1
Output #2
5
Input #3
10 5 3
1 1 1 1 1 1 1 1 1 1
Output #3
2
Input #4
20 6 946667802
786820955 250480341 710671229 946667801 19271059 404902145 251317818 22712439 520643153 344670307 274195604 561032101 140039457 543856068 521915711 857077284 499774361 419370025 744280520 249168130
Output #4
6
API Response (JSON)
{
  "problem": {
    "name": "Subsegments with Large Sums",
    "description": {
      "content": "You are given a sequence of positive integers $A=(A_1,A_2,\\cdots,A_N)$ of length $N$. Consider dividing this sequence into $K$ non-empty contiguous subsequences. Among these $K$ contiguous subsequence",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "arc168_e"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You are given a sequence of positive integers $A=(A_1,A_2,\\cdots,A_N)$ of length $N$.\nConsider dividing this sequence into $K$ non-empty contiguous subsequences. Among these $K$ contiguous subsequence...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments