Codeforces Round 477 (rated, Div. 1, based on VK Cup 2018 Round 3)


A. Stairs and Elevators
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 6 1 1 3
2
5
3
1 1 5 6
1 3 5 4
3 3 5 3
Output
7
5
4
----------------------------------------------------------------------------------------------------
B. Resource Distribution
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 8 16
3 5 2 9 8 7
Output
Yes
3 2
1 2 6
5 4
Input
4 20 32
21 11 11 12
Output
Yes
1 3
1
2 3 4
Input
4 11 32
5 5 16 16
Output
No
Input
5 12 20
7 8 4 11 9
Output
No
----------------------------------------------------------------------------------------------------
C. Big Secret
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 2 3
Output
No
Input
6
4 7 7 12 31 61
Output
Yes
4 12 7 31 7 61 
----------------------------------------------------------------------------------------------------
D. Aztec Catacombs
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 4
1 2
2 3
1 3
3 4
Output
2
1 3 4 
Input
4 2
1 2
2 3
Output
4
1 2 3 1 4 
----------------------------------------------------------------------------------------------------
E. May Holidays
time limit per test: 5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
3 3
1 2 0 3 -4 7
2 3 -2 5 1 6
3 1 0 4 0 4
Output
0.25
----------------------------------------------------------------------------------------------------
