Codeforces Round 317 [AimFund Thanks-Round] (Div. 2)


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

Examples
Input
3 3
2 1
1 2 3
3 4 5
Output
YES
Input
3 3
3 3
1 2 3
3 4 5
Output
NO
Input
5 2
3 1
1 1 1 1 1
2 2
Output
YES
----------------------------------------------------------------------------------------------------
B. Order Book
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 2
B 10 3
S 50 2
S 40 1
S 50 6
B 20 4
B 25 10
Output
S 50 8
S 40 1
B 25 10
B 20 4
----------------------------------------------------------------------------------------------------
C. Lengthening Sticks
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
3 2
1 2 4
Output
1
Input
5 2
3 -5 3 -5 3
Output
0
Input
6 3
4 3 4 3 2 5
Output
3
----------------------------------------------------------------------------------------------------
E. CNF 2
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 2
2 1 -2
2 2 -1
Output
YES
11
Input
4 3
1 1
1 2
3 -1 -2 3
1 -3
Output
NO
Input
5 6
2 1 2
3 1 -2 3
4 -3 5 4 6
2 -6 -4
1 5
Output
YES
100010
----------------------------------------------------------------------------------------------------
