結果

問題 No.1715 Dinner 2
ユーザー lloyzlloyz
提出日時 2021-11-21 01:03:35
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 847 bytes
コンパイル時間 973 ms
コンパイル使用メモリ 10,872 KB
実行使用メモリ 8,492 KB
最終ジャッジ日時 2023-09-03 14:43:51
合計ジャッジ時間 3,463 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,800 KB
testcase_01 AC 16 ms
7,888 KB
testcase_02 AC 17 ms
7,852 KB
testcase_03 AC 16 ms
7,844 KB
testcase_04 AC 16 ms
7,960 KB
testcase_05 AC 16 ms
7,848 KB
testcase_06 WA -
testcase_07 AC 16 ms
7,884 KB
testcase_08 AC 16 ms
7,816 KB
testcase_09 AC 17 ms
7,800 KB
testcase_10 WA -
testcase_11 AC 19 ms
8,368 KB
testcase_12 AC 19 ms
8,492 KB
testcase_13 AC 20 ms
8,388 KB
testcase_14 AC 19 ms
8,472 KB
testcase_15 AC 20 ms
8,448 KB
testcase_16 AC 18 ms
8,420 KB
testcase_17 AC 18 ms
8,240 KB
testcase_18 WA -
testcase_19 AC 17 ms
7,856 KB
testcase_20 AC 17 ms
7,960 KB
testcase_21 WA -
testcase_22 AC 16 ms
7,896 KB
testcase_23 AC 17 ms
7,796 KB
testcase_24 AC 16 ms
7,984 KB
testcase_25 AC 17 ms
7,984 KB
testcase_26 AC 16 ms
7,808 KB
testcase_27 AC 17 ms
7,848 KB
testcase_28 AC 17 ms
7,808 KB
testcase_29 AC 16 ms
7,848 KB
testcase_30 AC 17 ms
7,984 KB
testcase_31 AC 17 ms
8,316 KB
testcase_32 AC 20 ms
8,440 KB
testcase_33 AC 20 ms
8,460 KB
testcase_34 AC 19 ms
8,404 KB
testcase_35 AC 19 ms
8,460 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

n, d = map(int, input().split())
P = [list(map(int, input().split())) for _ in range(n)]

Plus = []
Zero = []
Nega = []
for i in range(n):
    if P[i][0] <= P[i][1]:
        Plus.append(P[i])
    elif P[i][0] == P[i][1]:
        Zero.append(P[i])
    else:
        Nega.append(P[i])

if len(Plus) >= 2:
    Plus.sort(key=lambda x: x[0])
    print(min(-Plus[0][0], -Plus[0][0] + Plus[0][1] - Plus[1][0]))
elif len(Plus) == 1:
    if len(Zero) >= 1:
        Zero.sort(key=lambda x: x[0])
        print(max(-Plus[0][0], -Zero[0][0]))
    else:
        Nega.sort(key=lambda x: x[1] - x[0], reverse=True)
        print((-Nega[0][0] + Nega[0][1]) * (n // 2))
else:
    Nega.sort(key=lambda x: x[1] - x[0], reverse=True)
    print((-Nega[0][0] + Nega[0][1]) * (n - n // 2) + \
        (-Nega[1][0] + Nega[1][1]) * (n // 2))

0