Codeforces Round 615 (Div. 3)


A. Collecting Coins
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
5 3 2 8
100 101 102 105
3 2 1 100000000
10 20 15 14
101 101 101 3
Output
YES
YES
NO
NO
YES
----------------------------------------------------------------------------------------------------
B. Collecting Packages
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
5
1 3
1 2
3 3
5 5
4 3
2
1 0
0 1
1
4 3
Output
YES
RUUURRRRUU
NO
YES
RRRRUUU
----------------------------------------------------------------------------------------------------
C. Product of Three Numbers
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
64
32
97
2
12345
Output
YES
2 4 8 
NO
NO
NO
YES
3 5 823 
----------------------------------------------------------------------------------------------------
D. MEX maximizing
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7 3
0
1
2
2
0
0
10
Output
1
2
3
3
4
4
7
Input
4 3
1
2
1
2
Output
0
0
0
0
----------------------------------------------------------------------------------------------------
E. Obtain a Permutation
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3
3 2 1
1 2 3
4 5 6
Output
6
Input
4 3
1 2 3
4 5 6
7 8 9
10 11 12
Output
0
Input
3 4
1 6 3 4
5 10 7 8
9 2 11 12
Output
2
----------------------------------------------------------------------------------------------------
F. Three Paths on a Tree
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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