시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 1024 MB | 7 | 3 | 2 | 33.333% |
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: