Truck Driver

AtCoder
IDabc430_c
Time2000ms
Memory256MB
Difficulty
> In AtCoder Country, there is a rule that "a truck driver must take a break of at least $B$ minutes when driving for $A$ minutes or more." You are given a string $S$ of length $N$ consisting of `a` and `b`, and positive integers $A$ and $B$. Find the number of integer pairs $(l,r)$ that satisfy all of the following conditions. * $1\leq l \leq r \leq N$ * The number of `a` in the substring from the $l$\-th character through the $r$\-th character of $S$ is greater than or equal to $A$. * The number of `b` in the substring from the $l$\-th character through the $r$\-th character of $S$ is less than $B$. ## Constraints * $1\leq N \leq 3\times 10^5$ * $1 \leq A,B \leq N$ * $S$ is a string of length $N$ consisting of `a` and `b`. * All input numbers are integers. ## Input The input is given from Standard Input in the following format: $N$ $A$ $B$ $S$ [samples]
Samples
Input #1
11 4 2
abbaaabaaba
Output #1
3

The pairs $(l,r)$ that satisfy the conditions are $(4,8),(4,9),(5,9)$, which is three pairs.
Input #2
13 1 2
bbbbbbbbbbbbb
Output #2
0

There are no pairs $(l,r)$ that satisfy the conditions.
API Response (JSON)
{
  "problem": {
    "name": "Truck Driver",
    "description": {
      "content": "> In AtCoder Country, there is a rule that \"a truck driver must take a break of at least $B$ minutes when driving for $A$ minutes or more.\" You are given a string $S$ of length $N$ consisting of `a` ",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc430_c"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "> In AtCoder Country, there is a rule that \"a truck driver must take a break of at least $B$ minutes when driving for $A$ minutes or more.\"\n\nYou are given a string $S$ of length $N$ consisting of `a` ...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments