Educational Codeforces Round 82 (Rated for Div. 2)


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

Examples
Input
3
010011
0
1111000
Output
2
0
0
----------------------------------------------------------------------------------------------------
B. National Project
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
5 1 1
8 10 10
1000000 1 1000000
Output
5
8
499999500000
----------------------------------------------------------------------------------------------------
C. Perfect Keyboard
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
ababa
codedoca
abcda
zxzytyz
abcdefghijklmnopqrstuvwxyza
Output
YES
bacdefghijklmnopqrstuvwxyz
YES
edocabfghijklmnpqrstuvwxyz
NO
YES
xzytabcdefghijklmnopqrsuvw
NO
----------------------------------------------------------------------------------------------------
D. Fill The Bag
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
10 3
1 32 1
23 4
16 1 4 1
20 5
2 1 16 1 8
Output
2
-1
0
----------------------------------------------------------------------------------------------------
E. Erase Subsequences
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
ababcd
abcba
a
b
defi
fed
xyz
x
Output
YES
NO
NO
YES
----------------------------------------------------------------------------------------------------
F. Number of Components
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2 10
2 1 1
1 2 1
2 2 1
1 1 2
3 1 2
1 2 2
2 2 2
2 1 2
3 2 4
2 1 5
Output
2
4
3
3
4
4
4
2
2
4
----------------------------------------------------------------------------------------------------
G. Sum of Prefix Sums
time limit per test: 6 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
4 2
3 2
4 1
1 3 3 7
Output
36
----------------------------------------------------------------------------------------------------
