Codeforces Round 175 (Div. 2)


A. Slightly Decreasing Permutations
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 2
Output
1 5 2 4 3
Input
3 0
Output
1 2 3
Input
3 2
Output
3 2 1
----------------------------------------------------------------------------------------------------
B. Find Marble
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 2 1
2 3 4 1
Output
3
Input
4 3 3
4 1 3 2
Output
0
Input
4 3 4
1 2 3 4
Output
-1
Input
3 1 3
2 1 3
Output
-1
----------------------------------------------------------------------------------------------------
C. Building Permutation
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
3 0
Output
2
Input
3
-1 -1 2
Output
6
----------------------------------------------------------------------------------------------------
D. Permutation Sum
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
Output
18
Input
5
Output
1800
----------------------------------------------------------------------------------------------------
E. Positions in Permutations
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 0
Output
1
Input
2 1
Output
0
Input
3 2
Output
4
Input
4 1
Output
6
Input
7 4
Output
328
----------------------------------------------------------------------------------------------------
