| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 1024 MB | 63 | 27 | 17 | 35.417% |
Two players are playing a game. They are given an array $a_1 , a_2 , \dots , a_n$ as well as an array $b_1 , b_2 , \dots , b_m$.
The game consists of m rounds. Players are participating in rounds alternatively. During the $i$-th round (for $i$ from 1ドル$ to $m$) the corresponding player (first player, if $i$ is odd, and second if $i$ is even) has to do exactly one of the following:
The first player wants to minimize the sum of the remaining elements in the array $a$ after all $m$ rounds, and the second wants to maximize it. Find the sum of the remaining elements in the array $a$ after all $m$ rounds if both players are playing optimally.
The first line contains two integers $n,ドル $m$ (1ドル ≤ n ≤ 2 ⋅ 10^4,ドル 1ドル ≤ m ≤ 2 ⋅ 10^5$) - the length of the array $a$ and the number of rounds in the game.
The second line contains $n$ integers $a_1 , a_2 , \dots , a_n$ ($-4 ⋅ 10^{14} ≤ a_i ≤ 4 ⋅ 10^{14}$) - the elements of the array $a$.
The third line contains $m$ integers $b_1 , b_2 , \dots , b_m$ (1ドル ≤ b_i ≤ 4 ⋅ 10^{14}$) - the elements of the array $b$.
Output a single integer - the sum of the remaining elements of the array $a$ after all $m$ rounds if both players are playing optimally.
| 번호 | 배점 | 제한 |
|---|---|---|
| 1 | 3 | $m = 1$ |
| 2 | 6 | $b_{i+1} = b_{i}$ (1ドル ≤ i < m$), i.e. all elements of the array $b$ are the same |
| 3 | 15 | $b_{i+1} \bmod b_i = 0$ (1ドル ≤ i < m$) |
| 4 | 9 | 1ドル ≤ m ≤ 7$ |
| 5 | 11 | 1ドル ≤ m ≤ 20$ |
| 6 | 15 | 1ドル ≤ m ≤ 100$ |
| 7 | 18 | 1ドル ≤ a_i , b_i ≤ 10^9$ |
| 8 | 11 | $m \bmod 2 = 0,ドル $b_{2i-1} = b_{2i}$ (1ドル ≤ i ≤ \frac{m}{2}$) |
| 9 | 12 | No additional constraints |
6 2 2 2 5 2 2 7 2 5
7
5 1 -5000111000 -5000222000 -15 5 2 5
-10000333010
In the first sample, one possible flow of the game is the following: