Playrix Codescapes Cup (Codeforces Round 413, rated, Div. 1 + Div. 2)


A. Carrot Cakes
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
8 6 4 5
Output
YES
Input
8 6 4 6
Output
NO
Input
10 3 11 4
Output
NO
Input
4 2 1 4
Output
YES
----------------------------------------------------------------------------------------------------
B. T-shirt buying
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
300 200 400 500 911
1 2 1 2 3
2 1 3 2 1
6
2 3 1 2 1 1
Output
200 400 300 500 911 -1 
Input
2
1000000000 1
1 1
1 2
2
2 1
Output
1 1000000000 
----------------------------------------------------------------------------------------------------
C. Fountains
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 7 6
10 8 C
4 3 C
5 6 D
Output
9
Input
2 4 5
2 5 C
2 1 D
Output
0
Input
3 10 10
5 5 C
5 5 C
10 11 D
Output
10
----------------------------------------------------------------------------------------------------
D. Field expansion
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3 2 4 4
2 5 4 10
Output
1
Input
3 3 3 3 5
2 3 5 4 2
Output
0
Input
5 5 1 2 3
2 2 3
Output
-1
Input
3 4 1 1 3
2 3 2
Output
3
----------------------------------------------------------------------------------------------------
E. Aquarium decoration
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 3 2
3 2 2 1
2
1 2
2
1 3
Output
7
Input
4 3 2
3 2 2 1
2
1 2
3
4 1 3
Output
6
Input
4 2 2
3 2 2 1
2
1 2
3
4 1 3
Output
-1
----------------------------------------------------------------------------------------------------
F. Beautiful fountains rows
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 5
2 4
Output
23
Input
3 6
2 4
3 6
4 4
Output
19
----------------------------------------------------------------------------------------------------
G. Cut the pie
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 1
0 0
0 3
3 0
1 1
Output
2.67794504460098710000
Input
5 3
6 5
6 3
5 0
0 0
0 5
5 4
3 3
5 2
Output
0.60228734612690049000
1.27933953226473580000
2.85805511179015910000
----------------------------------------------------------------------------------------------------
