Codeforces Round 406 (Div. 2)


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

Examples
Input
20 2
9 19
Output
82
Input
2 1
16 12
Output
-1
----------------------------------------------------------------------------------------------------
B. Not Afraid
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 2
1 -3
4 -2 3 2 -3
Output
YES
Input
5 2
5 3 -2 1 -1 5
3 -5 2 5
Output
NO
Input
7 2
3 -1 6 7
7 -5 4 2 4 7 -3 4
Output
YES
----------------------------------------------------------------------------------------------------
C. Berzerk
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
3 5 1
2 3 2 3 17
2 3 2 2 16
2 2 2 3 3
3 3 1 1 12
1 3 3 17
Output
0 28 12 
Input
4 3 1
3 4 1 3 12
2 2 3 4 10
1 2 4 16
Output
0 -1 -1 12 
----------------------------------------------------------------------------------------------------
E. Till I Collapse
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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