Codeforces Round 574 (Div. 2)


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

Examples
Input
5 3
1
3
1
1
2
Output
4
Input
10 3
2
1
3
2
3
3
1
3
1
2
Output
9
----------------------------------------------------------------------------------------------------
B. Sport Mafia
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 1
Output
0
Input
9 11
Output
4
Input
5 0
Output
3
Input
3 2
Output
1
----------------------------------------------------------------------------------------------------
C. Basketball Exercise
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
9 3 5 7 3
5 8 1 4 5
Output
29
Input
3
1 2 9
10 1 1
Output
19
Input
1
7
4
Output
7
----------------------------------------------------------------------------------------------------
D1. Submarine in the Rybinsk Sea (easy edition)
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
12 33 45
Output
26730
Input
2
123 456
Output
1115598
Input
1
1
Output
11
Input
5
1000000000 1000000000 1000000000 1000000000 1000000000
Output
265359409
----------------------------------------------------------------------------------------------------
D2. Submarine in the Rybinsk Sea (hard edition)
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
12 3 45
Output
12330
Input
2
123 456
Output
1115598
----------------------------------------------------------------------------------------------------
E. OpenStreetMap
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 4 2 1
1 2 3 59
Output
111
----------------------------------------------------------------------------------------------------
F. Geometers Anonymous Club
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3
0 0
1 0
0 1
4
1 1
1 2
0 2
0 1
3
2 2
1 2
2 1
3
1 2
2 3
1 3
Output
5
5
6
----------------------------------------------------------------------------------------------------
