EPIC Institute of Technology Round Summer 2024 (Div. 1 + Div. 2)


A. Upload More RAM
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
5 1
2 2
2 3
1 7
11 5
100 100
Output
5
3
4
1
51
9901
----------------------------------------------------------------------------------------------------
B. K-Sort
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
3
1 7 9
5
2 1 4 7 6
4
1 3 2 4
1
179
9
344 12 37 60 311 613 365 328 675
Output
0
3
2
0
1821
----------------------------------------------------------------------------------------------------
C. Basil's Garden
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
3
1 1 2
2
3 1
1
9
5
7 4 4 3 2
Output
4
3
9
7
----------------------------------------------------------------------------------------------------
D. World is Mine
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
9
4
1 4 2 3
3
1 1 1
5
1 4 2 3 4
4
3 4 1 4
1
1
8
4 3 2 5 6 8 3 4
7
6 1 1 3 5 3 1
11
6 11 6 8 7 5 3 11 2 3 5
17
2 6 5 3 9 1 6 2 5 6 3 2 3 9 6 1 6
Output
2
1
3
2
1
3
2
4
4
----------------------------------------------------------------------------------------------------
E. Wonderful Tree!
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
5
9 3 4 1 2
1 1 3 3
2
5 3
1
2
36 54
1
3
0 0 0
1 2
Output
3
2
0
0
----------------------------------------------------------------------------------------------------
F1. Interesting Problem (Easy Version)
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
5
1 5 3 2 4
8
2 1 3 4 5 6 7 8
3
1 2 3
4
1 2 4 4
5
4 4 1 3 5
1
1
Output
2
3
1
2
0
0
----------------------------------------------------------------------------------------------------
F2. Interesting Problem (Hard Version)
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
5
1 5 3 2 4
8
2 1 3 4 5 6 7 8
3
1 2 3
4
1 2 4 4
5
4 4 1 3 5
1
1
Output
2
3
1
2
0
0
----------------------------------------------------------------------------------------------------
G1. Spinning Round (Easy Version)
time limit per test: 7 seconds
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
8
5
2 1 4 3 5
?????
2
1 2
??
3
3 1 2
???
7
5 3 1 6 4 2 7
???????
5
5 2 1 3 4
?????
6
6 2 3 4 5 1
??????
8
1 7 5 6 2 8 4 3
????????
12
6 10 7 1 8 5 12 2 11 3 4 9
????????????
Output
4
1
2
6
4
5
5
8
----------------------------------------------------------------------------------------------------
G2. Spinning Round (Hard Version)
time limit per test: 7 seconds
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
8
5
2 1 4 3 5
R?RL?
2
1 2
LR
3
3 1 2
L?R
7
5 3 1 6 4 2 7
?R?R?R?
5
5 2 1 3 4
?????
6
6 2 3 4 5 1
?LLRLL
8
1 7 5 6 2 8 4 3
?R??????
12
6 10 7 1 8 5 12 2 11 3 4 9
????????????
Output
3
-1
-1
4
4
3
5
8
----------------------------------------------------------------------------------------------------
H. Fumo Temple
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2
3 4
5
3
5
1 1
0
Output
? 1 1
? 3 3
? 3 2
! 1 4
? 1 1
! 1 1
----------------------------------------------------------------------------------------------------
