Educational Codeforces Round 124 (Rated for Div. 2)


A. Playoff
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2
3
1
Output
7
1
----------------------------------------------------------------------------------------------------
B. Prove Him Wrong
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2
512
3
Output
YES
1 337
NO
YES
31 4 159
----------------------------------------------------------------------------------------------------
C. Fault-tolerant Network
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
3
1 10 1
20 4 25
4
1 1 1 1
1000000000 1000000000 1000000000 1000000000
Output
31
1999999998
----------------------------------------------------------------------------------------------------
D. Nearest Excluded Points
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
2 2
1 2
2 1
3 2
2 3
5 5
Output
1 1
1 1
2 0
3 1
2 4
5 4
Input
8
4 4
2 4
2 2
2 3
1 4
4 2
1 3
3 3
Output
4 3
2 5
2 1
2 5
1 5
4 1
1 2
3 2
----------------------------------------------------------------------------------------------------
E. Sum of Matchings
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5
4 6
4 9
2 6
3 9
1 8
5 10
2 7
3 7
1 10
5 8
Output
314
----------------------------------------------------------------------------------------------------
F. Tower Defense
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3
5 1
7 4
4 2
4
0 14
1 10
3 16
10 16
Output
4
Input
5
2 1
4 1
5 4
7 5
8 3
9
1 21
2 18
3 14
4 24
5 8
6 25
7 19
8 24
9 24
Output
40
----------------------------------------------------------------------------------------------------
