아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Game

시간 제한2초메모리 제한512 MB

요약
격자 상태에서 두 플레이어가 번갈아 이동하며 언제든 게임을 끝낼 수 있을 때, 완벽한 플레이로 얻는 최종 점수를 구한다.
난이도

보통10점 중 6점

유형
게임 이론, 그리디
정답자
아직 제출이 없습니다

문제

There are two arrays of integers aa and bb of length nn and mm, respectively.

There is a chosen position in each array. Denote the chosen position in aa as cc and in bb as dd. The state is a tuple (c,dc, d). The chosen positions are never out of bounds, i.e. 1≤c≤n1 \leq c \leq n and 1≤d≤m1 \leq d \leq m. At the start of the game both cc and dd are equal to 11.

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 1022810^{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⋅mn \cdot m states and each state appears no more than 10228−110^{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_da\_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 nn and mm (1≤n,m≤1051 \leq n, m \leq 10^5), lengths of arrays aa and bb, respectively.

The second line contains nn integers a_ia\_i (1≤a_i≤1081 \leq a\_i \leq 10^8), the elements of aa.

The third line contains mm integers b_ib\_i (1≤b_i≤1081 \leq b\_i \leq 10^8), the elements of bb.

출력

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

예제6

  1. 예제 1

    입력
    2 2
    1 3
    1 3
    
    예상 출력
    2
    
  2. 예제 2

    입력
    2 1
    3 2
    2
    
    예상 출력
    4
    
  3. 예제 3

    입력
    3 1
    3 3 2
    2
    
    예상 출력
    5
    
  4. 예제 4

    입력
    4 5
    10 1 2 3
    10 1 2 3 4
    
    예상 출력
    11
    
  5. 예제 5

    입력
    6 7
    4 5 6 1 2 3
    5 2 1 3 4 6 7
    
    예상 출력
    7
    
  6. 예제 6

    입력
    4 3
    64 16 4 1
    32 8 2
    
    예상 출력
    33