Codeforces Round 251 (Div. 2)


A. Devu, the Singer and Churu, the Joker
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 30
2 2 1
Output
5
Input
3 20
2 1 1
Output
-1
----------------------------------------------------------------------------------------------------
B. Devu, the Dumb Guy
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 3
4 1
Output
11
Input
4 2
5 1 2 1
Output
10
Input
3 3
1 1 1
Output
6
----------------------------------------------------------------------------------------------------
C. Devu and Partitioning of the Array
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 5 3
2 6 10 5 9
Output
YES
1 9
1 5
1 10
1 6
1 2
Input
5 5 3
7 14 2 9 5
Output
NO
Input
5 3 1
1 2 3 7 5
Output
YES
3 5 1 3
1 7
1 2
----------------------------------------------------------------------------------------------------
D. Devu and his Brother
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
5
6 2
7 2
6 3
6 4
7 4
Output
2
6
9
10
20
----------------------------------------------------------------------------------------------------
