IndiaHacks 2016 - Online Edition (Div. 1 + Div. 2)


A. Bear and Three Balls
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
18 55 16 17
Output
YES
Input
6
40 41 43 44 44 44
Output
NO
Input
8
5 972 3 4 1 4 970 971
Output
YES
----------------------------------------------------------------------------------------------------
B. Bear and Compressing
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 5
ab a
cc c
ca a
ee c
ff d
Output
4
Input
2 8
af e
dc d
cc f
bc b
da b
eb a
bb b
ff c
Output
1
Input
6 2
bb a
ba a
Output
0
----------------------------------------------------------------------------------------------------
C. Bear and Up-Down
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
2 8 4 7 7
Output
2
Input
4
200 150 100 50
Output
1
Input
10
3 2 1 4 1 4 1 4 1 4
Output
8
Input
9
1 2 3 4 5 6 7 8 9
Output
0
----------------------------------------------------------------------------------------------------
D. Delivery Bears
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 4 3
1 2 2
2 4 1
1 3 1
3 4 2
Output
1.5000000000
Input
5 11 23
1 2 3
2 3 4
3 4 5
4 5 6
1 3 4
2 4 5
3 5 6
1 4 2
2 5 3
1 5 2
3 2 30
Output
10.2222222222
----------------------------------------------------------------------------------------------------
E. Bear and Forgotten Tree 2
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 4 2
1 2
2 3
4 2
4 1
Output
possible
Input
6 5 3
1 2
1 3
1 4
1 5
1 6
Output
impossible
----------------------------------------------------------------------------------------------------
F. Paper task
time limit per test: 3 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
10
()()()()()
Output
5
Input
7
)(())()
Output
3
----------------------------------------------------------------------------------------------------
G. Move by Prime
time limit per test: 5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
60 60 40
Output
6
Input
4
1 2 3 4
Output
24
----------------------------------------------------------------------------------------------------
