PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000011. Tối đa hóa MEX (MEX maximizing)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Tối đa hóa MEX (MEX maximizing)
MEX maximizing
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Start with an empty array. Each of queries appends a nonnegative number . After each append, you may increase or decrease any element by any number of times without making it negative. The MEX is the smallest absent nonnegative integer. Output the maximum obtainable MEX after each query. Operations are reset before the next query.
Input
First line: . Then lines, each with an appended value .
Output
Print lines, the maximum MEX after each query.
Subtasks
- Subtask 1 (20 points): ;
- Subtask 2 (30 points): ;
- Subtask 3 (50 points): ;
Examples
Input
4 3
1
2
1
2
Output
0
0
0
0
Explanation
No appended element has remainder modulo . Such moves preserve remainders, hence is always missing.