QOJ.ac

QOJ

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

#1441. 特殊游戏

Statistics

Dmytryk 和 Petro 正在玩一个游戏。他们有 $2n$ 张卡片,卡片上的整数值从 $1$ 到 $2n$,且所有值各不相同。游戏开始时,每位玩家恰好拥有 $n$ 张卡片。

游戏共进行 $n$ 轮,由 Dmytryk 在第一轮先手出牌。在每一轮中,先手玩家打出一张卡片。随后,后手玩家(在看到先手玩家的卡片后)打出一张自己的卡片。卡片数值较大的玩家赢得该轮,并获得下一轮的先手权。两张卡片随后从游戏中移除。

游戏有一条附加规则:在每一轮中,如果后手玩家拥有比他看到的先手玩家的卡片数值更大的卡片,他必须打出一张这样的卡片。

每位玩家的目标都是最大化自己赢得的轮数。在双方均采取最优策略的情况下,求 Dmytryk 最多能赢得多少轮。

第一行包含一个整数 $n$ ($1 \le n \le 1000$)。第二行包含 $n$ 个整数,表示 Dmytryk 的卡片。第三行包含 $n$ 个整数,表示 Petro 的卡片。

问题的答案。

样例

输入格式 1

3
1 2 5
3 4 6

输出格式 1

1

输入格式 2

2
4 3
1 2

输出格式 2

2

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.