Codeforces Round 266 (Div. 2)


A. Cheap Travel
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 2 1 2
Output
6
Input
5 2 2 3
Output
8
----------------------------------------------------------------------------------------------------
B. Wonder Room
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3 5
Output
18
3 6
Input
2 4 4
Output
16
4 4
----------------------------------------------------------------------------------------------------
C. Number of Ways
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 2 3 0 3
Output
2
Input
4
0 1 -1 0
Output
1
Input
2
4 1
Output
0
----------------------------------------------------------------------------------------------------
D. Increase Sequence
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2
1 1 1
Output
4
Input
5 1
1 1 1 1 1
Output
1
Input
4 3
3 2 1 1
Output
0
----------------------------------------------------------------------------------------------------
E. Information Graph
time limit per test: 1 second
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4 9
1 4 3
2 4
3 3 1
1 2 3
2 2
3 1 2
1 3 1
2 2
3 1 3
Output
YES
NO
YES
----------------------------------------------------------------------------------------------------
