#P10086. [ROIR 2022] 口算比赛 (Day 1)
[ROIR 2022] 口算比赛 (Day 1)
Background
Translated from ROIR 2022 D1T1。
In a mental arithmetic contest with unusual rules, the judges write integers on the blackboard. The contestant needs to decide by themselves to execute the following two types of operations:
- Erase the -th number and write the number in that position. That is, if the blackboard originally shows , then after this operation the sequence becomes 。
- Cyclically shift the sequence to the right by positions. That is, if the blackboard originally shows , then after this operation the sequence becomes $a_{n−k+1}, a_{n−k+2}, \dots , a_n, a_1, a_2, \dots , a_{n−k}$。
Problem Description
After each operation, the contestant must report to the jury the sum of all numbers currently on the blackboard. To verify the contestant’s answers, the judges need to compute these sums themselves。
Input Format
The first line contains an integer , the number of numbers on the blackboard at the beginning。
The second line contains integers separated by spaces, the initial numbers on the blackboard 。
The third line contains an integer , the number of operations to be performed。
In the next lines, each line describes one operation in the following format:
1 i x: the contestant replaces the -th number with 。2 k: the contestant cyclically shifts the sequence to the right by positions。
Output Format
Output lines, each containing one integer. The -th line should contain the sum of all numbers on the blackboard after performing the first operations。
6
4 1 2 1 5 3
5
2 3
1 3 10
1 4 4
2 1
1 1 -10
16
23
23
23
11
3
1000000000 1000000000 1000000000
3
1 2 999999999
2 2
1 2 999999999
2999999999
2999999999
2999999998
Hint
Explanation of Sample :
Initially, the sequence on the blackboard is: 。
After the first operation, the sequence is cyclically shifted to the right by positions. The new sequence is 。The sum of all numbers is 。
After the second operation, we replace the third element with 。The new sequence is 。The sum of all numbers is 。
After the third operation, we replace the fourth element with 。Since the fourth element is already , the sequence does not change. The sum is still 。
After the fourth operation, the sequence is cyclically shifted to the right by position and becomes ,and the sum does not change。
Finally, after the fifth operation, the sequence becomes 。The final sum of the sequence is 。
This problem uses bundled testdata。
| Subtask | Score | Special Property |
|---|---|---|
| and all operations are of the first type | ||
| and in all second-type operations, | ||
| None |
Constraints: for of the data, , , 。For the first type of operation, 。For the second type of operation, , 。
Translated by ChatGPT 5