VK Cup 2012 Qualification Round 1


A. Next Round
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
8 5
10 9 8 7 7 7 5 5
Output
6
Input
4 2
0 0 0 0
Output
0
----------------------------------------------------------------------------------------------------
B. Taxi
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 2 4 3 3
Output
4
Input
8
2 3 4 4 2 1 3 1
Output
5
----------------------------------------------------------------------------------------------------
C. Cd and pwd commands
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
pwd
cd /home/vasya
pwd
cd ..
pwd
cd vasya/../petya
pwd
Output
/
/home/vasya/
/home/
/home/petya/
Input
4
cd /a/b
pwd
cd ../a/b
pwd
Output
/a/b/
/a/a/b/
----------------------------------------------------------------------------------------------------
D. Ice Sculptures
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
3 2
30000 15000
40000 15000
50000 15000
Output
49999
Input
5 1
1 20000
10000 10000
20000 20000
25000 10000
80000 60000
Output
39999
----------------------------------------------------------------------------------------------------
