結果
問題 | No.1715 Dinner 2 |
ユーザー | lloyz |
提出日時 | 2021-11-21 01:14:54 |
言語 | Python3 (3.11.6 + numpy 1.26.0 + scipy 1.11.3) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,380 bytes |
コンパイル時間 | 93 ms |
コンパイル使用メモリ | 10,840 KB |
実行使用メモリ | 8,604 KB |
最終ジャッジ日時 | 2023-09-03 15:08:25 |
合計ジャッジ時間 | 2,810 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 16 ms
8,136 KB |
testcase_01 | AC | 18 ms
8,104 KB |
testcase_02 | AC | 17 ms
8,032 KB |
testcase_03 | WA | - |
testcase_04 | AC | 16 ms
8,156 KB |
testcase_05 | AC | 16 ms
8,068 KB |
testcase_06 | WA | - |
testcase_07 | AC | 16 ms
8,072 KB |
testcase_08 | AC | 16 ms
8,108 KB |
testcase_09 | AC | 15 ms
8,080 KB |
testcase_10 | WA | - |
testcase_11 | AC | 18 ms
8,520 KB |
testcase_12 | AC | 19 ms
8,584 KB |
testcase_13 | AC | 19 ms
8,604 KB |
testcase_14 | AC | 18 ms
8,476 KB |
testcase_15 | AC | 19 ms
8,544 KB |
testcase_16 | AC | 18 ms
8,032 KB |
testcase_17 | AC | 17 ms
8,136 KB |
testcase_18 | WA | - |
testcase_19 | AC | 16 ms
8,100 KB |
testcase_20 | AC | 16 ms
8,072 KB |
testcase_21 | WA | - |
testcase_22 | AC | 16 ms
8,036 KB |
testcase_23 | AC | 15 ms
8,040 KB |
testcase_24 | AC | 16 ms
8,080 KB |
testcase_25 | AC | 16 ms
8,172 KB |
testcase_26 | AC | 16 ms
8,180 KB |
testcase_27 | AC | 16 ms
8,108 KB |
testcase_28 | AC | 16 ms
8,092 KB |
testcase_29 | AC | 16 ms
8,140 KB |
testcase_30 | AC | 15 ms
8,068 KB |
testcase_31 | AC | 16 ms
8,092 KB |
testcase_32 | AC | 19 ms
8,512 KB |
testcase_33 | AC | 19 ms
8,512 KB |
testcase_34 | AC | 19 ms
8,480 KB |
testcase_35 | AC | 18 ms
8,512 KB |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
ソースコード
n, d = map(int, input().split()) P = [list(map(int, input().split())) for _ in range(n)] if d == 1: P.sort(key=lambda x: x[0]) print(-P[0][0]) exit() 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], x[0] - x[1])) print(min(-Plus[0][0], -Plus[0][0] + Plus[0][1] - Plus[1][0])) elif len(Plus) == 1: if len(Zero) >= 1: Plus.sort(key=lambda x: x[0]) 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) if -Plus[0][0] + Plus[0][1] - Nega[0][0] + Nega[0][1] >= 0: print(max(-Plus[0][0], -Nega[0][0], -Plus[0][0] + Plus[0][1] - Nega[0][0])) else: print((-Plus[0][0] + Plus[0][1]) * (n - n // 2) +\ (-Nega[0][0] + Nega[0][1]) * (n // 2)) else: if len(Zero) >= 1: Nega.sort(key=lambda x: x[1] - x[0], reverse=True) print((-Nega[0][0] + Nega[0][1]) * (d // 2)) else: Nega.sort(key=lambda x: x[1] - x[0], reverse=True) print((-Nega[0][0] + Nega[0][1]) * (d - d // 2) + \ (-Nega[1][0] + Nega[1][1]) * (d // 2))