AT_scpc2026_div1_h.SCSC Card Game
入门
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
SCSC has N members. Each member has one spade card and one club card. Member i's spade card has integer Si written on it, and their club card has integer Ci written on it.
The members of SCSC are standing in a line in the order from member 1 to member N to play the SCSC card game. Terra, the host of the game, must choose two adjacent members and make them play one of the following two duels.
-
The two members each reveal the spade card with the smallest integer among their spade cards. The member who reveals the card with the larger integer wins. The losing member gives all of their club cards to the winning member and leaves.
-
The two members each reveal the club card with the smallest integer among their club cards. The member who reveals the card with the larger integer wins. The losing member gives all of their spade cards to the winning member and leaves.
Any cards that the leaving member does not give to the winning member are no longer used in the game. If there were members on both sides of the leaving member, those two members become adjacent to each other.
After N−1 duels, exactly one member remains.
The last remaining member gives Terra one card with the smallest integer among their spade cards and one card with the smallest integer among their club cards, then leaves.
Let Ssum be the sum of the integers written on all spade cards initially held by all members, and let Csum be the sum of the integers written on all club cards initially held by all members. Let Sf be the integer written on the spade card Terra receives at the end, and let Cf be the integer written on the club card Terra receives at the end. Then Terra's final score is (Ssum−Sf)(Csum−Cf).
Terra wants the final score to be as small as possible. Find the minimum possible score Terra can obtain.
SCSC 有 N 名成员。每名成员各持有一张黑桃牌和一张梅花牌。第 i 名成员的黑桃牌上写有一个整数 Si,梅花牌上写有一个整数 Ci。
SCSC 的成员按编号从 1 到 N 的顺序排成一列,以进行 SCSC 牌类游戏。游戏主持人 Terra 必须选择两名相邻的成员,并让他们进行以下两种对决之一:
-
两名成员各自展示其所有黑桃牌中数字最小的一张。展示数字较大者获胜。失败者将其全部梅花牌交给获胜者,然后离场。
-
两名成员各自展示其所有梅花牌中数字最小的一张。展示数字较大者获胜。失败者将其全部黑桃牌交给获胜者,然后离场。
失败者未交给获胜者的那些牌将不再参与后续游戏。若离场成员两侧均有其他成员,则这两名成员变为相邻。
经过 N−1 轮对决后,恰好只剩一名成员。
最后剩下的这名成员向 Terra 提交一张其所有黑桃牌中数字最小的黑桃牌,以及一张其所有梅花牌中数字最小的梅花牌,然后离场。
记 Ssum 为所有成员初始持有的黑桃牌上数字之和,Csum 为所有成员初始持有的梅花牌上数字之和;记 Sf 为 Terra 最终收到的黑桃牌上的数字,Cf 为 Terra 最终收到的梅花牌上的数字。则 Terra 的最终得分为 (Ssum−Sf)(Csum−Cf)。
Terra 希望最终得分尽可能小。求 Terra 能获得的最小可能得分。
输入格式
The input is given from Standard Input in the following format:
N
S1 C1
S2 C2
⋮
SN CN
输入从标准输入中按以下格式给出:
N
S1 C1
S2 C2
⋮
SN CN
输出格式
Output the minimum possible score Terra can obtain.
输出Terra能够获得的最小可能得分。
输入输出样例
输入#1
2 3 4 4 5
输出#1
15
说明/提示
表示言語
/ /
Constraints
- 1≤N≤5000
- 1≤Si,Ci≤50000
- For all 1≤i<j≤N, Si=Sj and Ci=Cj.
- All given numbers are integers.
表示语言
/ /
限制条件
- 1≤N≤5000
- 1≤Si,Ci≤50000
- 对于所有 1≤i<j≤N,有 Si=Sj 且 Ci=Cj。
- 所有给定的数均为整数。
输入解题思路,AI测评打分。不知道怎么写?