Codeforces Round 601 (Div. 2)


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

Examples
Input
3
4 0
5 14
3 9
Output
2
3
2
----------------------------------------------------------------------------------------------------
B. Fridge Lockers
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
4 4
1 1 1 1
3 1
1 2 3
3 3
1 2 3
Output
8
1 2
4 3
3 2
4 1
-1
12
3 2
1 2
3 1
----------------------------------------------------------------------------------------------------
C. League of Leesins
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
4 3 2
2 3 5
4 1 2
Output
1 4 2 3 5 
----------------------------------------------------------------------------------------------------
D. Feeding Chicken
time limit per test: 1.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
3 5 3
..R..
...R.
....R
6 4 6
R..R
R..R
RRRR
RRRR
R..R
R..R
5 5 4
RRR..
R.R..
RRR..
R..R.
R...R
2 31 62
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
Output
11122
22223
33333
aacc
aBBc
aBBc
CbbA
CbbA
CCAA
11114
22244
32444
33344
33334
abcdefghijklmnopqrstuvwxyzABCDE
FGHIJKLMNOPQRSTUVWXYZ0123456789
----------------------------------------------------------------------------------------------------
E1. Send Boxes to Alice (Easy Version)
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 0 1
Output
2
Input
1
1
Output
-1
----------------------------------------------------------------------------------------------------
E2. Send Boxes to Alice (Hard Version)
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
4 8 5
Output
9
Input
5
3 10 2 1 5
Output
2
Input
4
0 5 15 10
Output
0
Input
1
1
Output
-1
----------------------------------------------------------------------------------------------------
F. Point Ordering
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
15
-1
1
Output
1 1 4 6
2 1 5 6
2 2 1 4
0 1 3 4 2 6 5
----------------------------------------------------------------------------------------------------
