Problems
Farmer John wants to fairly split haybales between his two favorite cows Bessie and Elsie. He has
Farmer John is considering splitting a contiguous range of haybales
You are given
Input
First line contains
Second line contains
Third line contains
Next
Output
Output
Subtask
| # | Score | Condition |
|---|---|---|
| #1 | 20 | |
| #2 | 30 | At most |
| #3 | 50 | 추가 제약 조건 없음 |
Example #1
2
3 1
15
1 1 -2
1 1 -1
1 1 0
1 1 1
1 1 2
1 2 -2
1 2 -1
1 2 0
1 2 1
1 2 2
2 2 -2
2 2 -1
2 2 0
2 2 1
2 2 2
1
2
3
-2
-1
0
1
2
-1
0
-1
0
1
0
1
For the 1st query, Elsie starts with
For the 3rd query, Elsie and Bessie start with the same number of hay. After processing haybale
For the 9th query, Bessie starts with
Example #2
5
4 4 3 1 1
7
1 1 20
1 2 20
1 5 20
1 1 0
1 5 0
1 4 0
3 5 2
16
12
7
4
1
2
1
In the 5th query, there are