Codeforces Round 555 (Div. 3)


A. Reachable Numbers
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1098
Output
20
Input
10
Output
19
----------------------------------------------------------------------------------------------------
B. Long Number
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1337
1 2 5 4 6 6 3 1 9
Output
1557
Input
5
11111
9 8 7 6 5 4 3 2 1
Output
99999
Input
2
33
1 1 1 1 1 1 1 1 1
Output
33
----------------------------------------------------------------------------------------------------
C1. Increasing Subsequence (easy version)
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
2 1 5 4 3
Output
4
LRRR
Input
7
1 3 5 6 7 4 2
Output
7
LRLRLLL
Input
3
1 2 3
Output
3
LLL
Input
4
1 2 4 3
Output
4
LLRL
----------------------------------------------------------------------------------------------------
C2. Increasing Subsequence (hard version)
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 2 4 3 2
Output
4
LRRR
Input
7
1 3 5 6 5 4 2
Output
6
LRLRRR
Input
3
2 2 2
Output
1
R
Input
4
1 2 4 3
Output
4
LLRR
----------------------------------------------------------------------------------------------------
D. N Problems During K Days
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
26 6
Output
YES
1 2 4 5 6 8 
Input
8 3
Output
NO
Input
1 1
Output
YES
1 
Input
9 4
Output
NO
----------------------------------------------------------------------------------------------------
E. Minimum Array
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
0 1 2 1
3 2 1 1
Output
1 0 0 2 
Input
7
2 5 1 5 3 4 3
2 4 3 5 6 5 1
Output
0 0 0 1 0 2 4 
----------------------------------------------------------------------------------------------------
F. Maximum Balanced Circle
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
4 3 5 1 2 2 1
Output
5
2 1 1 2 3
Input
5
3 7 5 1 5
Output
2
5 5 
Input
3
5 1 4
Output
2
4 5 
Input
7
2 2 3 2 1 2 2
Output
7
1 2 2 2 2 3 2 
----------------------------------------------------------------------------------------------------
G. Inverse of Rows and Columns
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 2
1 1
0 1
Output
YES
00
10
Input
3 4
0 0 0 1
0 0 0 0
1 1 1 1
Output
YES
010
0000
Input
3 3
0 0 0
1 0 1
1 1 0
Output
NO
----------------------------------------------------------------------------------------------------
