Codeforces Round 408 (Div. 2)


A. Buying A House
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 1 20
0 27 32 21 19
Output
40
Input
7 3 50
62 0 0 0 99 33 22
Output
30
Input
10 5 100
1 0 1 0 0 0 0 0 1 1
Output
20
----------------------------------------------------------------------------------------------------
B. Find The Bone
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
5
1 2 3 4 5
1 2
2 3
3 4
4 5
Output
5
Input
7
38 -29 87 93 39 28 -55
1 2
2 5
3 2
2 4
1 7
7 6
Output
93
Input
5
1 2 7 6 7
1 5
5 3
3 4
2 4
Output
8
----------------------------------------------------------------------------------------------------
D. Police Stations
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

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

Examples
Input
5 4
1 1 5 19
1 2 5 1
2 5 100
1 1 5 100
Output
YES
19 0 0 0 1
Input
5 2
1 1 5 0
1 1 5 100
Output
NO
----------------------------------------------------------------------------------------------------
