Codeforces Round 531 (Div. 3)


A. Integer Sequence Dividing
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
Output
0
Input
5
Output
1
Input
6
Output
1
----------------------------------------------------------------------------------------------------
B. Array K-Coloring
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 2
1 2 2 3
Output
YES
1 1 2 2
Input
5 2
3 2 1 2 3
Output
YES
2 1 1 2 1
Input
5 2
2 1 1 2 1
Output
NO
----------------------------------------------------------------------------------------------------
C. Doors Breaking and Repairing
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 3 2
2 3 1 3 4 2
Output
6
Input
5 3 3
1 2 4 2 3
Output
2
Input
5 5 6
1 2 6 10 3
Output
2
----------------------------------------------------------------------------------------------------
D. Balanced Ternary String
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
121
Output
021
Input
6
000000
Output
001122
Input
6
211200
Output
211200
Input
6
120110
Output
120120
----------------------------------------------------------------------------------------------------
E. Monotonic Renumeration
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 2 1 2 3
Output
2
Input
2
100 1
Output
2
Input
4
1 3 3 7
Output
4
----------------------------------------------------------------------------------------------------
F. Elongated Matrix
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 2
9 9
10 8
5 3
4 3
Output
5
Input
2 4
1 2 3 4
10 3 7 3
Output
0
Input
6 1
3
6
2
5
1
4
Output
3
----------------------------------------------------------------------------------------------------
