Codeforces Round 594 (Div. 2)


A. Integer Points
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3
3
1 3 2
2
0 3
1
1
1
1
1
2
1
1
Output
3
1
0
----------------------------------------------------------------------------------------------------
B. Grow The Tree
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3
1 2 3
Output
26
Input
4
1 1 2 2
Output
20
----------------------------------------------------------------------------------------------------
C. Ivan the Fool and the Probability Theory
time limit per test: 1 second
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2 3
Output
8
----------------------------------------------------------------------------------------------------
D1. The World Is Just a Programming Task (Easy Version)
time limit per test: 1 second
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
10
()()())(()
Output
5
8 7
Input
12
)(()(()())()
Output
4
5 10
Input
6
)))(()
Output
0
1 1
----------------------------------------------------------------------------------------------------
D2. The World Is Just a Programming Task (Hard Version)
time limit per test: 1 second
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
10
()()())(()
Output
5
8 7
Input
12
)(()(()())()
Output
4
5 10
Input
6
)))(()
Output
0
1 1
----------------------------------------------------------------------------------------------------
E. Queue in the Train
time limit per test: 1 second
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5 314
0 310 942 628 0
Output
314 628 1256 942 1570 
----------------------------------------------------------------------------------------------------
F. Catowice City
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
3 4
1 1
2 2
3 3
1 3
3 7
1 1
1 2
1 3
2 2
3 1
3 2
3 3
1 1
1 1
2 4
1 1
1 2
2 1
2 2
Output
Yes
2 1
1 3 
2 
Yes
1 2
2 
1 3 
No
No
----------------------------------------------------------------------------------------------------
