PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000247. Mike và những ly bia (Mike and Foam)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Mike và những ly bia (Mike and Foam)
Mike and Foam
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Mike manages a shelf with beer types numbered through . Type has foam amount . Initially the shelf is empty. Each of operations toggles type : remove it if present, otherwise insert it. After every operation print the number of pairs present on the shelf with .
Input
Line 1 contains . Line 2 contains exactly integers . Each of the next lines contains the index whose presence is toggled.
Output
Print exactly lines; the -th line is the valid pair count after operation .
Subtasks
- Subtask 1 (20 points): ; for every ; in every operation.
- Subtask 2 (30 points): ; for every ; in every operation.
- Subtask 3 (50 points): ; for every ; in every operation.
Examples
Example 1
Input
5 6
1 2 3 4 6
1
2
3
4
5
1
Output
0
1
3
5
6
2
Explanation
The inserted values are 1, 2, 3, 4, 6; the final query removes 1.