QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 1024 MB Total points: 100

#8370. T3

统计

Alice 和 Bob 在玩游戏。

有一个 $n\times m$ 大小的棋盘,棋盘的第 $x$ 行第 $y$ 列记为 $(x,y)$。

开始时棋盘上有一个车位于 $(1,1)$。Alice 和 Bob 轮流操作,Alice 先操作。对于每次操作,玩家都有两种选择:

  1. 将车移动至同行或同列的某个格子上,注意不能移动到车本来所在的格子。换句话说,若车当前位于 $(x,y)$,则它可被移动至 $(c,y)\ (1\leq c\leq n,c\neq x)$ 或 $(x,d)\ (1\leq d\leq m,d\neq y)$。
  2. 结束游戏。

Alice 和 Bob 发现这个游戏可能永远不会结束,于是他们规定在任意时刻,每个格子被车移动到的次数要严格小于 $10^9$。注意,开始时格子 $(1,1)$ 算作被移动到一次。

只是单纯地移动棋子非常无聊,所以他们给出了两个分别长为 $n,m$ 的序列 $a,b$。结束游戏时,若车当前位于 $(x,y)$,则游戏的分数为 $a_x+b_y$,Alice 想让游戏的分数尽量小,而 Bob 想让游戏的分数尽量大。你需要求出在双方的最优策略下,游戏的分数是多少。

输入格式

第一行两个整数 $n,m$ 表示棋盘大小。

第二行 $n$ 个整数 $a_i$,表示序列 $a$。

第三行 $m$ 个整数 $b_i$,表示序列 $b$。

输出格式

输出一行一个整数,表示答案。

样例输入 1

2 1
3 2
2

样例输出 1

4

样例输入 2

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

样例输出 2

7

样例解释

样例 $1$ 中如果双方要移动,那么目标都是唯一确定的,而 Bob 在他的第 $10^9-1$ 轮中移动时发现此时会将格子 $(1,1)$ 经过的次数变为 $10^9$,而这不是合法的操作。所以 Bob 只能在他的某次操作中选择结束游戏,游戏的分数即为 $a_2+b_1=4$。

样例 $2$ 的决策树大小至少为 $5^{10^9}$ 量级,这里空太小,画不开。

数据范围

对于所有数据,$1\leq n,m\leq 2\times 10^5$,$1\leq a_i,b_i\leq 10^8$。

子任务 $1$($14$ 分):$n,m\leq 4$。

子任务 $2$($11$ 分):$b_i=1$。

子任务 $3$($15$ 分):$n,m\leq 10$。

子任务 $4$($16$ 分):$n,m\leq 10^3$。

子任务 $5$($19$ 分):$n,m\leq 5\times 10^4$。

子任务 $6$($25$ 分):无特殊限制。

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.