Codeforces Beta Round 75 (Div. 1 Only)


A. Newspaper Headline
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
abc
xyz
Output
-1
Input
abcd
dabc
Output
2
----------------------------------------------------------------------------------------------------
B. Queue
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
10 8 5 3 50 45
Output
2 1 0 -1 0 -1 
Input
7
10 4 6 3 2 8 15
Output
4 2 1 0 -1 -1 -1 
Input
5
10 3 1 10 11
Output
1 0 -1 -1 -1 
----------------------------------------------------------------------------------------------------
C. Ski Base
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 4
1 3
2 3
1 2
1 2
Output
0
0
1
3
----------------------------------------------------------------------------------------------------
D. Grocer's Problem
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
3 5 6 1 2 4
Output
2
4
1 3 6 4 
3 6 4 1 
2
2 5 
5 2 
Input
14
9 13 11 3 10 7 12 14 1 5 4 6 8 2
Output
3
4
2 13 8 14 
13 8 14 2 
5
6 7 12 5 10 
7 12 6 10 5 
5
3 11 4 1 9 
11 4 3 9 1 
----------------------------------------------------------------------------------------------------
E. Igloo Skyscraper
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 4
4 1
3 5
6 2
3 5
6 5
1 5 2
1 3 5
1 1 0
1 5 0
Output
5
2
1
5
Input
5 4
6 1
5 1
2 5
4 3
6 1
2 4 1
3 4 5
1 4 5
1 2 0
Output
3
3
3
1
----------------------------------------------------------------------------------------------------
