COMPFEST 14 - Preliminary Online Mirror (Unrated, ICPC Rules, Teams Preferred)


A. Accumulation of Dominoes
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 4
Output
9
Input
2 1
Output
1
----------------------------------------------------------------------------------------------------
B. Basketball Together
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 180
90 80 70 60 50 100
Output
2
----------------------------------------------------------------------------------------------------
C. Circular Mirror
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 2
10 10 6 14
Output
10
Input
1 2
10
Output
2
----------------------------------------------------------------------------------------------------
D. Deducing Sortability
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
6 3
1
4
5
Output
17
1
3
4
Input
1 0
Output
1
----------------------------------------------------------------------------------------------------
E. Electrical Efficiency
time limit per test: 3 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3
1 2 3
1 2
2 3
Output
0
Input
4
6 14 6 6
1 2
2 3
2 4
Output
12
----------------------------------------------------------------------------------------------------
F. Field Photography
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 5
10 11
8 8
2
12
5
Output
2
3
----------------------------------------------------------------------------------------------------
G. Garage
time limit per test: 1 second
memory limit per test: 128 megabytes
input: standard input
output: standard output

Examples
Input
3
Output
7
----------------------------------------------------------------------------------------------------
H. Hot Black Hot White
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
4 10 9 14
Output
0
1001
----------------------------------------------------------------------------------------------------
I. Imitating the Key Tree
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
3 2
1 3
4 3
Output
540
----------------------------------------------------------------------------------------------------
J. Journey
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 2 4
2 3 5
3 4 4
Output
8
Input
5
1 2 45
1 3 50
1 4 10
1 5 65
Output
115
----------------------------------------------------------------------------------------------------
K. Kingdom of Criticism
time limit per test: 3 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5
2 6 5 6 2
9
1 5 10
2 5
1 1 3
3 3 6
3 8 9
1 2 9
2 3
2 2
2 4
Output
10
7
9
7
----------------------------------------------------------------------------------------------------
L. Lemper Cooking Competition
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
2 -1 -1 5 2 -2 9
Output
4
Input
5
-1 -2 -3 -4 -5
Output
-1
----------------------------------------------------------------------------------------------------
M. Moving Both Hands
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

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