QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 128 MB Total points: 100 Hackable ✓

#17188. 国王游戏

統計

怡逢 H 国国庆,国王邀请 $n$ 位大臣来玩一个有奖游戏。首先,他让每个大臣在左、右手上面分别写下一个整数,国王自己也在左、右手上各写一个整数。然后,让这 $n$ 位大臣排成一排,国王站在队伍的最前面。排好队后,所有的大臣都会获得国王奖励的若干金币,每位大臣获得的金币数分别为:排在该大臣前面的所有人的左手上的数的乘积除以他自己右手上的数,然后向下取整得到的结果。

国王不希望某一个大臣获得特别多的奖赏,所以他想请你帮他重新安排一下队伍的顺序,使得获得奖赏最多的大臣,所获奖赏尽可能的少。注意,国王的位置始终在队伍的最前面。

输入格式

第一行包含一个整数 $n$,表示大臣的人数。

第二行包含两个整数 $a$ 和 $b$,之间用一个空格隔开,分别表示国王左手和右手上的整数。

接下来 $n$ 行,每行包含两个整数 $a$ 和 $b$,之间用一个空格隔开,分别表示每个大臣左手和右手上的整数。

输出格式

输出只有一行,包含一个整数,表示重新排列后的队伍中获奖赏最多的大臣所获得的金币数。

样例数据

样例输入

3
1 1
2 3
7 4
4 6

样例输出

2

输入输出样例说明

  • 按 1、2、3 号大臣这样排列队伍,获得奖赏最多的大臣所获得金币数为 2;
  • 按 1、3、2 这样排列队伍,获得奖赏最多的大臣所获得金币数为 2;
  • 按 2、1、3 这样排列队伍,获得奖赏最多的大臣所获得金币数为 2;
  • 按 2、3、1 这样排列队伍,获得奖赏最多的大臣所获得金币数为 9;
  • 按 3、1、2 这样排列队伍,获得奖赏最多的大臣所获得金币数为 2;
  • 按 3、2、1 这样排列队伍,获得奖赏最多的大臣所获得金币数为 9。

因此,奖赏最多的大臣最少获得 2 个金币,答案输出 2。

子任务

对于 20% 的数据,有 $1\le n\le 10$,$0< a,b< 8$;

对于 40% 的数据,有 $1\le n\le 20$,$0< a,b< 8$;

对于 60% 的数据,有 $1\le n\le 100$;

对于 60% 的数据,保证答案不超过 $10^9$;

对于 100% 的数据,有 $1\le n\le 1{,}000$,$0< a,b< 100\,00$。

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.