QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 1024 MB Total points: 100

#4715. 卷土重来

Statistics

COMEBACK

在去过公园后,Antonio 回到了家,他发现了一个包含 $n$ 个非负整数的数组和一个数字 $X$。感到无聊的他决定用这个数组进行 $n$ 步游戏。因此,在每一步中,Antonio 执行以下 2 个操作:

  1. 找出数组中所有和小于或等于 $X$ 的子序列,并记录这些子序列的和的总和及其数量。
  2. 将数组向左循环移位一个位置。

任务

确定 Antonio 在每一步中记录的值。

输入格式

第一行包含数字 $n$ 和 $X$。 第二行包含 $n$ 个空格分隔的元素,对应于该数组。

输出格式

输出包含 $n$ 行: 第 $i$ 行包含两个整数,由空格分隔,分别表示第 $i$ 步中有效子序列的和的总和及其数量。

数据范围

  • $n \le 100\,000, X \le 1\,000\,000\,000$
  • 数组元素在 $0$ 到 $10^6$ 之间。
  • 给定数组的子序列由连续位置上的元素组成。

子任务

子任务 分值 额外输入限制
1 40 $n \le 1\,000$
2 100 $n \le 100\,000$

样例

输入 1

3 5
1 2 3

输出 1

14 5
15 5
13 5

说明

第 1 阶段。有效子序列的和的总和:$1 + 2 + 3 + (1 + 2) + (2 + 3) = 14$ 共有 5 个有效子序列。 数组变为 $2, 3, 1$。

第 2 阶段。有效子序列的和的总和:$2 + 3 + 1 + (2 + 3) + (3 + 1) = 15$ 共有 5 个有效子序列。 数组变为 $3, 1, 2$。

第 3 阶段。有效子序列的和的总和:$3 + 1 + 2 + (3 + 1) + (1 + 2) = 13$ 共有 5 个有效子序列。 数组变为 $1, 2, 3$。

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
EditorialOpen Official EditorialQingyu- Download

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.