远端评测题 1000ms 125MiB

[NOIP 2012 提高组] 国王游戏

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Problem Description

It is the National Day of country H, and the king invites nn ministers to play a prize game. First, he asks each minister to write an integer on his left hand and an integer on his right hand; the king also writes one integer on his left hand and one on his right hand. Then the nn ministers line up in a row, with the king standing at the very front. After the lineup is fixed, every minister will receive some gold coins from the king. The number of coins a minister receives equals the product of the numbers on the left hands of all people standing before that minister, divided by the integer on his own right hand, and then taking the floor.

The king does not want any single minister to get too many coins, so he asks you to rearrange the order of the ministers to make the maximum number of coins received by any minister as small as possible. Note that the king always stands at the very front.

Input Format

The first line contains an integer nn, the number of ministers.

The second line contains two integers aa and bb separated by a space, representing the integers on the king’s left and right hands, respectively.

Each of the next nn lines contains two integers aa and bb separated by a space, representing one minister’s left- and right-hand integers, respectively.

Output Format

Output one integer, the maximum number of coins received by any minister in the optimal arrangement.

3 
1 1 
2 3 
7 4 
4 6 
2

Hint

[Input/Output Sample Explanation]

If the lineup is 1, 2, 3, the maximum number of coins received is 2. If the lineup is 1, 3, 2, the maximum number of coins received is 2. If the lineup is 2, 1, 3, the maximum number of coins received is 2. If the lineup is 2, 3, 1, the maximum number of coins received is 9. If the lineup is 3, 1, 2, the maximum number of coins received is 2. If the lineup is 3, 2, 1, the maximum number of coins received is 9. Therefore, the minimum possible maximum is 2, so output 2.

Constraints: For 20% of the testdata, 1n101 \le n \le 10, 0<a,b<80 < a, b < 8. For 40% of the testdata, 1n201 \le n \le 20, 0<a,b<80 < a, b < 8. For 60% of the testdata, 1n1001 \le n \le 100. For 60% of the testdata, it is guaranteed that the answer does not exceed 10910^9. For 100% of the testdata, 1n10001 \le n \le 1000, 0<a,b<100000 < a, b < 10000.

NOIP 2012 Senior, Day 1, Problem 2.

Translated by ChatGPT 5

第 25 课:贪心算法

未认领
状态
已结束
题目
21
开始时间
2026-7-7 19:00
截止时间
2026-7-14 19:00
可延期
24 小时