結果
問題 |
No.1715 Dinner 2
|
ユーザー |
|
提出日時 | 2021-11-21 01:03:35 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 847 bytes |
コンパイル時間 | 336 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 11,136 KB |
最終ジャッジ日時 | 2024-06-12 20:26:50 |
合計ジャッジ時間 | 3,043 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 31 WA * 7 |
ソースコード
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))