Codeforces Round 326 (Div. 1)


A. Duff and Weight Lifting
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 1 2 3 3
Output
2
Input
4
0 1 2 3
Output
4
----------------------------------------------------------------------------------------------------
B. Duff in Beach
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 5 3
5 9 1
Output
10
Input
5 10 3
1 2 3 4 5
Output
25
----------------------------------------------------------------------------------------------------
C. Duff in the Army
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5 4 5
1 3
1 2
1 4
4 5
2 1 4 3
4 5 6
1 5 2
5 5 10
2 3 3
5 3 1
Output
1 3
2 2 3
0
3 1 2 4
1 2
----------------------------------------------------------------------------------------------------
D. Duff in Mafia
time limit per test: 6 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 7
2 1 3 7
3 1 1 6
5 4 1 8
4 5 1 1
3 2 2 3
4 5 2 5
2 3 2 4
Output
Yes
3 2
4 5
Input
3 5
3 2 1 3
1 3 1 1
3 2 1 4
1 3 2 2
1 3 2 10
Output
No
----------------------------------------------------------------------------------------------------
E. Duff as a Queen
time limit per test: 7 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 5
1 2 3 4 2
2 1 5
1 2 2 8
2 1 5
1 1 3 10
2 2 2
Output
8
16
1
----------------------------------------------------------------------------------------------------
F. Duff is Mad
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 5
a
ab
abab
ababab
b
1 5 4
3 5 4
1 5 2
1 5 3
1 4 1
Output
12
6
3
7
1
----------------------------------------------------------------------------------------------------
