欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF2086B.Large Array and Segments
Large Array and Segments
There is an array consisting of positive integers, and a positive integer . An array is created from array according to the following rules:
- contains numbers;
- the first numbers of array are the same as the numbers of array , that is, for ;
- for any , it holds that .
For example, if and , then .
Given a number , it is required to count the number of such positions (), for which there exists a position , such that the sum of the elements of array on the segment is at least (in other words, ).
Input
Each test consists of several test cases. The first line contains one integer () — the number of test cases. The description of the test cases follows.
The first line of each test case contains three integers , , (; ).
The second line of each test case contains integers ().
Additional constraints on the input:
- the sum of across all test cases does not exceed ;
- the sum of across all test cases does not exceed .
Output
For each test case, output one integer — the number of suitable positions in the array .
Note
In the first test case, the array looks like this:
$$[3, 4, 2, 1, 5, 3, 4, 2, 1, 5, 3, 4, 2, 1, 5]$$</p><p>There are$12$positions$l$for which there exists a suitable position$r$. Here are some (not all) of them:</p><ul> <li>$l = 1$, for which there is a position$r = 6$, the sum over the segment$[1, 6]$equals$18$; </li><li>$l = 2$, for which there is a position$r = 5$, the sum over the segment$[2, 5]$equals$12$; </li><li>$l = 6$, for which there is a position$r = 9$, the sum over the segment$[6, 9]$equals$10$. ## Samples ```input1 7 5 3 10 3 4 2 1 5 15 97623 1300111 105 95 108 111 118 101 95 118 97 108 111 114 97 110 116 1 100000 1234567891011 1 1 1 1 1 1 1 1 2 2 1 2 1 1 2 1 5 2 1 ``` ```output1 12 1452188 0 1 1 1 0 ```$$在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |