Codeforces Round 103 (Div. 2)


A. Arrival of the General
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
33 44 11 22
Output
2
Input
7
10 10 58 31 63 40 76
Output
10
----------------------------------------------------------------------------------------------------
B. Meeting
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 5 4 2
3
3 1 2
5 3 1
1 3 2
Output
4
Input
5 2 6 3
2
6 2 2
6 5 3
Output
0
----------------------------------------------------------------------------------------------------
C. Anagram Search
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
bb??x???
aab
Output
2
Input
ab?c
acb
Output
2
----------------------------------------------------------------------------------------------------
D. Missile Silos
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 6 1
1 2 1
1 3 3
2 3 1
2 4 1
3 4 1
1 4 2
2
Output
3
Input
5 6 3
3 1 1
3 2 1
3 4 1
3 5 1
1 2 6
4 5 8
4
Output
3
----------------------------------------------------------------------------------------------------
E. Competition
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3
2 3
3 2
3 3
Output
3
1 2 3 
----------------------------------------------------------------------------------------------------
