QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 64 MB 總分: 140

#13760. VUDU

统计

最近,年轻的 Mirko 一直在购买巫毒娃娃。考虑到他对尽可能便宜地购买非常感兴趣,他每天都在记录巫毒娃娃的价格。他的价格表包含了过去 $N$ 天内的娃娃价格,其中娃娃价格 $a_i$ 表示 $i$ 天前的娃娃价格。

Mirko 认为他发现了连续几天内娃娃的平均价格与随后一天的价格之间的某种联系。他想验证自己的直觉,并被一个非常有趣的问题所困扰:“对于给定的 $P$,在过去的 $N$ 天中,有多少个不同的连续子序列,其娃娃的平均价格大于或等于 $P$?”

如果两个连续子序列的起点或终点不同,则认为它们是不同的。

输入格式

第一行包含一个整数 $N$,表示序列的长度($1 \le N \le 1\,000\,000$)。

第二行包含 $N$ 个价格 $a_i$($0 \le a_i \le 1\,000\,000\,000$)。

第三行包含一个整数 $P$($0 \le P \le 1\,000\,000\,000$)。

输出格式

输出的唯一一行应包含对于给定的 $P$,Mirko 所提问题的答案。

子任务

对于 $30\%$ 的测试数据,序列长度 $N$ 将小于或等于 $10\,000$。

样例

输入样例 1

3
1 2 3
3

输出样例 1

1

输入样例 2

3
1 3 2
2

输出样例 2

5

输入样例 3

3
1 3 2
3

输出样例 3

1

说明

第一个样例解释:唯一一个平均值大于或等于 $3$ 的子序列是 $\{3\}$。

第二个样例解释:平均值大于或等于 $2$ 的子序列有 $\{1, 3\}$、$\{1, 3, 2\}$、$\{3\}$、$\{3, 2\}$、$\{2\}$。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.