Educational Codeforces Round 46 (Rated for Div. 2)


A. Codehorses T-shirts
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
XS
XS
M
XL
S
XS
Output
2
Input
2
XXXL
XXL
XXL
XXXS
Output
1
Input
2
M
XS
XS
M
Output
0
----------------------------------------------------------------------------------------------------
B. Light It Up
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 10
4 6 7
Output
8
Input
2 12
1 10
Output
9
Input
2 7
3 4
Output
6
----------------------------------------------------------------------------------------------------
C. Covered Points Count
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
0 3
1 3
3 8
Output
6 2 1 
Input
3
1 3
2 4
5 7
Output
5 2 0 
----------------------------------------------------------------------------------------------------
D. Yet Another Problem On a Subsequence
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2 1 1
Output
2
Input
4
1 1 1 1
Output
7
----------------------------------------------------------------------------------------------------
E. We Need More Bosses
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 5
1 2
2 3
3 1
4 1
5 2
Output
2
Input
4 3
1 2
4 3
3 2
Output
3
----------------------------------------------------------------------------------------------------
F. One Occurrence
time limit per test: 3 seconds
memory limit per test: 768 megabytes
input: standard input
output: standard output

Examples
Input
6
1 1 2 3 2 4
2
2 6
1 2
Output
4
0
----------------------------------------------------------------------------------------------------
G. Two-Paths
time limit per test: 3.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7 6
6 5 5 3 2 1 2
1 2 2
2 3 2
2 4 1
4 5 1
6 4 2
7 3 25
1 1
4 4
5 6
6 4
3 4
3 7
Output
9
9
9
8
12
-14
----------------------------------------------------------------------------------------------------
