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

23679번 - Game 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 (추가 시간 없음) 512 MB49222046.512%

문제

There are two arrays of integers $a$ and $b$ of length $n$ and $m,ドル respectively.

There is a chosen position in each array. Denote the chosen position in $a$ as $c$ and in $b$ as $d$. The state is a tuple ($c, d$). The chosen positions are never out of bounds, i.e. 1ドル \leq c \leq n$ and 1ドル \leq d \leq m$. At the start of the game both $c$ and $d$ are equal to 1ドル$.

Two players are playing a game taking turns alternately. On his turn each player must do one of the following:

  1. Move. Change the chosen position in one of the arrays. You can't change a chosen position to itself. It is not allowed to make a move which will result in a state appearing for the 10ドル^{228}$-th time. The starting state is considered as having appeared once at the beginning of the game.
  2. Screw you guys, I'm going home. Finish the game.

Note that there are $n \cdot m$ states and each state appears no more than 10ドル^{228} - 1$ times. Therefore the game is finite.

The score of the game is equal to the sum of elements on the chosen positions, i.e. $a_c + b_d$. The player who moves first minimizes it by playing accordingly and the one who moves second maximizes it.

What is the score of the game assuming perfect play from both sides?

입력

The first line contains two $n$ and $m$ (1ドル \leq n, m \leq 10^5$), lengths of arrays $a$ and $b,ドル respectively.

The second line contains $n$ integers $a_i$ (1ドル \leq a_i \leq 10^8$), the elements of $a$.

The third line contains $m$ integers $b_i$ (1ドル \leq b_i \leq 10^8$), the elements of $b$.

출력

Output a single integer --- the score of the game.

제한

예제 입력 1

2 2
1 3
1 3

예제 출력 1

2

예제 입력 2

2 1
3 2
2

예제 출력 2

4

예제 입력 3

3 1
3 3 2
2

예제 출력 3

5

예제 입력 4

4 5
10 1 2 3
10 1 2 3 4

예제 출력 4

11

예제 입력 5

6 7
4 5 6 1 2 3
5 2 1 3 4 6 7

예제 출력 5

7

예제 입력 6

4 3
64 16 4 1
32 8 2

예제 출력 6

33

힌트

출처

Contest > Open Cup > 2018/2019 Season > Stage 13: Grand Prix of Bytedance G번

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

출처

대학교 대회

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

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