Bubble Cup 14 - Finals Online Mirror (Unrated, ICPC Rules, Teams Preferred, Div. 1)


A. Weights
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
3 8 2 13 7
LLRLL
Output
3 L
2 R
8 R
13 L
7 L
----------------------------------------------------------------------------------------------------
B. Restaurant Game
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
4
0 1
left right
Output
0
----------------------------------------------------------------------------------------------------
C. Bubble Strike
time limit per test: 0.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7 1.0000
Output
6
----------------------------------------------------------------------------------------------------
D. Bubble Popping
time limit per test: 2.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
0 0
1 0
0 1
1 1
2
1 -1 3
-1 1 4
Output
4
2
Input
4
1 1
2 2
7 1
1 7
3
2 2 1
1 -5 4
-6 5 3
Output
3
2
3
----------------------------------------------------------------------------------------------------
E. Two Arrays
time limit per test: 5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 4
1 0 2
2 1 0
4 1 3
3 2 2 2 3
1 1 1 3 0
4 1 3
Output
4
4
Input
5 4
1 3 5 3 2
4 2 1 3 3
4 1 3
4 2 5
2 1 2 4 6
4 2 4
Output
18
26
68
----------------------------------------------------------------------------------------------------
F. Mars
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
9 8
17 0 12 6 10 8 2 4 5
2 3 12
2 3 6
2 4 6
4 6 2
2 8 2
1 2 17
1 8 2
9 9 14
Output
Yes
No
Yes
Yes
Yes
Yes
No
Yes
Input
4 1
7 21 14 0
1 4 1000000000
Output
Yes
----------------------------------------------------------------------------------------------------
G. Shortest path
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 2
0 0
-1 1
2 -2
0 1
-2 2
Output
7.478709
----------------------------------------------------------------------------------------------------
H. Hidden Fortress
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
1
2
1
Output
? 2 2
? 5 5
? 4 7
? 1 5
! 2 3 4 5
----------------------------------------------------------------------------------------------------
I. Desert
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 6
1 2
2 3
3 4
4 5
5 1
2 4
Output
20
Input
2 3
1 2
1 2
1 2
Output
5
----------------------------------------------------------------------------------------------------
J. Bob's Beautiful Array
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
5 5
Output
YES
2 3
Input
3
1 2 3
Output
YES
0 1 2
Input
3
2 4 5
Output
NO
Input
4
1 3 5 7
Output
YES
6 -3 4 1
----------------------------------------------------------------------------------------------------
