K. Masaoud LOVES PIZZAS

Codeforces
IDCF10216K
Time1000ms
Memory256MB
Difficulty
English · Original
Formal · Original
Today the dinner in NCD is Pizza. Because the dorm's restaurant is generous, each student will get a number of pizza slices. Masaoud is no longer a student in NCD, but he is hungry, so he will steal some slices from the students of NCD. But he is on a regime because he wants to become slim. So he wants to eat less than $X$ slices of pizza. There are $N$ students in the restaurant standing in a line. Each student $i$ has a plate that has $A_i$ slices of pizza in it. Masaoud will choose a group of students standing directly next to each other and steal all their pizzas. How many ways can Masaoud choose a group, so that their total number of pizza slices are less than $X$. in the first line $T$, number of test cases. For each test case, the first line contains $N$, $X$ ($1 <= N <= 10^5$,$1 <= X <= 10^9$) the number of students and the number given in the problem statement. the second line contains $N$ separated integers the number of pizza slices each student has ($1 <= A_i <= 10^9$). For each test case output the number of groups of students such that Masaoud can steal their slices. ## Input in the first line $T$, number of test cases.For each test case, the first line contains $N$, $X$ ($1 <= N <= 10^5$,$1 <= X <= 10^9$) the number of students and the number given in the problem statement.the second line contains $N$ separated integers the number of pizza slices each student has ($1 <= A_i <= 10^9$). ## Output For each test case output the number of groups of students such that Masaoud can steal their slices. [samples]
**Definitions** Let $ T \in \mathbb{Z} $ be the number of test cases. For each test case: - Let $ N \in \mathbb{Z} $ be the number of students. - Let $ X \in \mathbb{Z} $ be the maximum number of slices Masaoud can eat. - Let $ A = (A_1, A_2, \dots, A_N) $ be a sequence of positive integers representing the pizza slices per student. **Constraints** 1. $ 1 \le T \le \text{unspecified} $ 2. For each test case: - $ 1 \le N \le 10^5 $ - $ 1 \le X \le 10^9 $ - $ 1 \le A_i \le 10^9 $ for all $ i \in \{1, \dots, N\} $ **Objective** Count the number of contiguous subarrays $ A[i:j] = (A_i, A_{i+1}, \dots, A_j) $ with $ 1 \le i \le j \le N $ such that: $$ \sum_{k=i}^{j} A_k < X $$
API Response (JSON)
{
  "problem": {
    "name": "K. Masaoud LOVES PIZZAS",
    "description": {
      "content": "Today the dinner in NCD is Pizza. Because the dorm's restaurant is generous, each student will get a number of pizza slices. Masaoud is no longer a student in NCD, but he is hungry, so he will steal ",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10216K"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Today the dinner in NCD is Pizza. Because the dorm's restaurant is generous, each student will get a number of pizza slices.\n\nMasaoud is no longer a student in NCD, but he is hungry, so he will steal ...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ T \\in \\mathbb{Z} $ be the number of test cases.  \nFor each test case:  \n- Let $ N \\in \\mathbb{Z} $ be the number of students.  \n- Let $ X \\in \\mathbb{Z} $ be the maximum number...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments