logo AlgoBeat OnlineJudge
登录 注册

#208475. [USACO23FEB] Hungry Cow P

内存限制:512 MiB 时间限制:6000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

Note: The time limit for this problem is 6s, three times the default. The memory limit for this problem is 512MB, twice the default.

Bessie is a hungry cow. Each day, for dinner, if there is a haybale in the barn, she will eat one haybale. Farmer John does not want Bessie to starve, so some days he sends a delivery of haybales, which arrive in the morning (before dinner). In particular, on day , Farmer John sends a delivery of haybales .

Process updates as follows: Given a pair , update the number of haybales arriving on day to . After each update, output the sum of all days on which Bessie eats haybales modulo .

输入格式

, followed by lines containing the updates.

输出格式

The sum after each update modulo .

样例

样例输入 1

3
4 3
1 5
1 2

样例输出 1

15
36
18

样例输入 2

9
1 89
30 7
101 26
1 24
5 1
60 4
5 10
101 0
1 200

样例输出 2

4005
4656
7607
3482
3507
3753
4058
1107
24531

数据范围与提示

Explanation for Sample 1

Answers after each update:



SCORING

  • Input :
  • Inputs : Updates only increase the number of haybales arriving on day .
  • Inputs 11-22: No additional constraints.