Logo
(追記) (追記ここまで)

21127번 - Binary Supersonic Utahraptors 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB70605189.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.

제한

예제 입력 1

2 3 1
0 0
1 1 1
2

예제 출력 1

1

힌트

출처

Camp > Petrozavodsk Programming Camp > Winter 2021 > Day 8: Belarusian SU Contest, Yandex Cup, Grand Prix of Belarud I번

Contest > Open Cup > 2020/2021 Season > Stage 12: Grand Prix of Belarus I번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /