| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 512 MB | 70 | 60 | 51 | 89.474% |
Alexey and Boris are playing a game called Binary Supersonic Utahraptors (BSU).
Initially, Alexey has $n$ utahraptors, and Boris has $m$ utahraptors. Each utahraptor is either yellow or red.
Then, the players take $k$ turns described by integers $s_1, s_2, \ldots, s_k$. The $i$-th turn is performed as follows. First, Alexey chooses $s_i$ utahraptors that belong to him and gives them to Boris. Then, Boris chooses $s_i$ utahraptors that belong to him (the utahraptors that Alexey has just given to him may also be chosen) and gives them to Alexey.
When the $k$ moves are done, the score of the game is calculated. The score is equal to $|a_y - b_r|,ドル where $a_y$ is the number of yellow utahraptors Alexey has, and $b_r$ is the number of red utahraptors Boris has. Alexey's goal is to minimize the score, and Boris wants to maximize it.
Write a program that calculates the score of the game if both players use their optimal strategies.
The first line contains three integers $n,ドル $m,ドル $k,ドル the number of utahraptors obtained by Alexey, the number of utahraptors obtained by Boris, and the number of turns in the game (1ドル \le n, m, k \le 3 \cdot 10^5$).
The second line contains $n$ integers $a_i,ドル denoting Alexey's utahraptors (0ドル \le a_i \le 1$). If $a_i = 0,ドル then the $i$-th utahraptor is yellow, otherwise the $i$-th utahraptor is red.
The third line contains $m$ integers $b_i,ドル denoting Boris's utahraptors in the same manner as described above (0ドル \le b_i \le 1$).
The fourth line contains $k$ integers $s_i,ドル describing the numbers of utahraptors that players give to each other on the $i$-th turn (1ドル \le s_i \le \min\{n, m\}$).
Print the score of the game if both players play optimally.
2 3 1 0 0 1 1 1 2
1