Codeforces Round 446 (Div. 2)


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

Examples
Input
2
3 5
3 6
Output
YES
Input
3
6 8 9
6 10 12
Output
NO
Input
5
0 0 5 0 0
1 1 8 10 5
Output
YES
Input
4
4 1 0 3
5 2 2 3
Output
YES
----------------------------------------------------------------------------------------------------
B. Wrath
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
0 1 0 10
Output
1
Input
2
0 0
Output
2
Input
10
1 1 3 0 0 0 2 1 0 3
Output
3
----------------------------------------------------------------------------------------------------
C. Pride
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
2 2 3 4 6
Output
5
Input
4
2 4 6 8
Output
-1
Input
3
2 6 9
Output
4
----------------------------------------------------------------------------------------------------
D. Gluttony
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
1 2
Output
2 1 
Input
4
1000 100 10 1
Output
100 1 1000 10
----------------------------------------------------------------------------------------------------
E. Envy
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 7
1 2 2
1 3 2
2 3 1
2 4 1
3 4 1
3 5 2
4 5 2
4
2 3 4
3 3 4 5
2 1 7
2 1 2
Output
YES
NO
YES
NO
----------------------------------------------------------------------------------------------------
