Educational Codeforces Round 91 (Rated for Div. 2)


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

Examples
Input
3
4
2 1 4 3
6
4 6 1 2 5 3
5
5 3 1 2 4
Output
YES
2 3 4
YES
3 5 6
NO
----------------------------------------------------------------------------------------------------
B. Universal Solution
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
----------------------------------------------------------------------------------------------------
C. Create The Teams
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
5 10
7 11 2 9 5
4 8
2 4 2 3
4 11
1 3 3 7
Output
2
1
0
----------------------------------------------------------------------------------------------------
D. Berserk And Fireball
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 2
5 2 3
3 1 4 5 2
3 5
Output
8
Input
4 4
5 1 4
4 3 1 2
2 4 3 1
Output
-1
Input
4 4
2 1 11
1 3 2 4
1 3 2 4
Output
0
----------------------------------------------------------------------------------------------------
E. Merging Towers
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
7 4
1 2 3 3 1 4 3
3 1
2 3
2 4
Output
5
4
2
0
----------------------------------------------------------------------------------------------------
F. Strange Addition
time limit per test: 5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 3
14
2 4
2 1
1 0
Output
15
12
2
----------------------------------------------------------------------------------------------------
G. Circular Dungeon
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
1 2
Output
499122177 0 
Input
8
10 4 3 6 5 10 7 5
Output
499122193 249561095 249561092 873463811 499122178 124780545 623902721 0 
----------------------------------------------------------------------------------------------------
