Educational Codeforces Round 77 (Rated for Div. 2)


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

Examples
Input
4
1 10000
10000 1
2 6
4 6
Output
100000000
1
18
10
----------------------------------------------------------------------------------------------------
B. Obtain Two Zeroes
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
6 9
1 1
1 2
Output
YES
NO
YES
----------------------------------------------------------------------------------------------------
C. Infinite Fence
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 1 2
2 10 4
5 2 3
3 2 2
Output
OBEY
REBEL
OBEY
OBEY
----------------------------------------------------------------------------------------------------
D. A Game with Traps
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
4
3 9 1 -1
Output
0
Input
8
11 -1 13 19 24 7 17 5
Output
12
----------------------------------------------------------------------------------------------------
F. Colored Tree
time limit per test: 2.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 1
1 2
1 1
1 2
1 2
1 3
3 4
Output
22
----------------------------------------------------------------------------------------------------
