VK Cup 2015 - Round 1 (unofficial online mirror, Div. 1 only)


A. And Yet Another Bracket Sequence
time limit per test: 5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
()(())
Output
(())()
Input
()(
Output
(())
----------------------------------------------------------------------------------------------------
B. Group Photo 2 (online mirror version)
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
10 1
20 2
30 3
Output
180
Input
3
3 1
2 2
4 3
Output
21
Input
1
5 10
Output
50
----------------------------------------------------------------------------------------------------
C. Rooks and Rectangles
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 3 3 3
1 1
3 2
2 3
2 3 2 3
2 1 3 3
1 2 2 3
Output
YES
YES
NO
----------------------------------------------------------------------------------------------------
D. Social Network
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 2 10
17:05:53
17:05:58
17:06:01
22:39:47
Output
3
1
2
2
3
Input
1 2 86400
00:00:00
Output
No solution
----------------------------------------------------------------------------------------------------
E. The Art of Dealing with ATM
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 20
10 50 100 500 1000 5000
8
4200
100000
95000
96000
99000
10100
2015
9950
Output
6
20
19
20
-1
3
-1
-1
Input
5 2
1 2 3 5 8
8
1
3
5
7
9
11
13
15
Output
1
1
1
2
2
2
2
-1
----------------------------------------------------------------------------------------------------
