Codeforces Round 767 (Div. 1)


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

Examples
Input
6
5
1 0 2 0 3
8
2 2 3 4 0 1 2 0
1
1
5
0 1 2 3 4
4
0 1 1 0
10
0 0 2 1 1 1 0 0 1 1
Output
1
4 
2
5 1 
1
0 
1
5 
2
2 2 
4
3 2 2 0 
----------------------------------------------------------------------------------------------------
B. Peculiar Movie Preferences
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
6
5
zx
ab
cc
zx
ba
2
ab
bad
4
co
def
orc
es
3
a
b
c
3
ab
cd
cba
2
ab
ab
Output
YES
NO
NO
YES
YES
NO
----------------------------------------------------------------------------------------------------
C. Grid Xor
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2
1 5
5 1
4
1 14 8 9
3 1 5 9
4 13 11 1
1 15 4 11
4
2 4 1 6
3 7 3 10
15 9 4 2
12 7 15 1
Output
4
9
5
----------------------------------------------------------------------------------------------------
D1. Game on Sum (Easy Version)
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
3 3 2
2 1 10
6 3 10
6 4 10
100 1 1
4 4 0
69 4 20
Output
6
5
375000012
500000026
958557139
0
49735962
----------------------------------------------------------------------------------------------------
D2. Game on Sum (Hard Version)
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
3 3 2
2 1 10
6 3 10
6 4 10
100 1 1
4 4 0
69 4 20
Output
6
5
375000012
500000026
958557139
0
49735962
----------------------------------------------------------------------------------------------------
E. Groceries in Meteor Town
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
3
0 1 2 4
1 3 -1 6
0 -1 1 -1
14
-2 10
-1 10
0 10
1 10
2 10
3 10
4 10
5 10
6 10
-1 -2
0 -2
1 -2
2 -2
3 -2
Output
YES
YES
YES
YES
YES
NO
NO
NO
YES
YES
NO
NO
NO
YES
----------------------------------------------------------------------------------------------------
