Codeforces Round 660 (Div. 2)


A. Captain Flint and Crew Recruitment
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
7
23
31
36
44
100
258
Output
NO
NO
YES
14 10 6 1
YES
5 6 10 15
YES
6 7 10 21
YES
2 10 33 55
YES
10 21 221 6
----------------------------------------------------------------------------------------------------
B. Captain Flint and a Long Voyage
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
1
3
Output
8
998
----------------------------------------------------------------------------------------------------
C. Uncle Bogdan and Country Happiness
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
7 4
1 0 1 1 0 1 0
4 0 0 -1 0 -1 0
1 2
1 3
1 4
3 5
3 6
3 7
5 11
1 2 5 2 1
-11 -2 -6 -2 -1
1 2
1 3
1 4
3 5
Output
YES
YES
Input
2
4 4
1 1 1 1
4 1 -3 -1
1 2
1 3
1 4
3 13
3 3 7
13 1 4
1 2
1 3
Output
NO
NO
----------------------------------------------------------------------------------------------------
D. Captain Flint and Treasure
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 2 3
2 3 -1
Output
10
1 2 3 
Input
2
-1 100
2 -1
Output
99
2 1 
Input
10
-10 -1 2 2 5 -2 -3 -4 2 -6
-1 -1 2 2 -1 5 5 7 7 9
Output
-9
3 5 6 1 9 4 10 7 8 2
----------------------------------------------------------------------------------------------------
E. Uncle Bogdan and Projections
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3
1 6 2
4 6 4
4 6 6
Output
9.000000000
Input
3
2 5 1
4 6 4
7 8 2
Output
6.333333333
Input
2
1 3 1
4 7 1
Output
6.000000000
----------------------------------------------------------------------------------------------------
