結果
問題 | No.1715 Dinner 2 |
ユーザー | tamato |
提出日時 | 2021-10-22 23:04:11 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 243 ms / 2,000 ms |
コード長 | 1,607 bytes |
コンパイル時間 | 357 ms |
コンパイル使用メモリ | 82,420 KB |
実行使用メモリ | 76,252 KB |
最終ジャッジ日時 | 2024-09-23 06:58:48 |
合計ジャッジ時間 | 5,216 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 39 ms
53,048 KB |
testcase_01 | AC | 43 ms
59,604 KB |
testcase_02 | AC | 50 ms
62,028 KB |
testcase_03 | AC | 40 ms
53,100 KB |
testcase_04 | AC | 50 ms
61,780 KB |
testcase_05 | AC | 44 ms
58,716 KB |
testcase_06 | AC | 40 ms
52,528 KB |
testcase_07 | AC | 46 ms
61,900 KB |
testcase_08 | AC | 45 ms
60,144 KB |
testcase_09 | AC | 40 ms
53,476 KB |
testcase_10 | AC | 44 ms
59,016 KB |
testcase_11 | AC | 182 ms
76,252 KB |
testcase_12 | AC | 184 ms
75,916 KB |
testcase_13 | AC | 172 ms
75,828 KB |
testcase_14 | AC | 164 ms
75,564 KB |
testcase_15 | AC | 185 ms
75,804 KB |
testcase_16 | AC | 161 ms
76,084 KB |
testcase_17 | AC | 130 ms
75,672 KB |
testcase_18 | AC | 52 ms
68,452 KB |
testcase_19 | AC | 55 ms
68,824 KB |
testcase_20 | AC | 53 ms
67,408 KB |
testcase_21 | AC | 48 ms
63,756 KB |
testcase_22 | AC | 50 ms
68,092 KB |
testcase_23 | AC | 59 ms
73,240 KB |
testcase_24 | AC | 53 ms
67,328 KB |
testcase_25 | AC | 71 ms
75,576 KB |
testcase_26 | AC | 69 ms
75,688 KB |
testcase_27 | AC | 62 ms
72,972 KB |
testcase_28 | AC | 64 ms
73,260 KB |
testcase_29 | AC | 70 ms
75,472 KB |
testcase_30 | AC | 69 ms
75,384 KB |
testcase_31 | AC | 64 ms
74,588 KB |
testcase_32 | AC | 228 ms
75,756 KB |
testcase_33 | AC | 222 ms
76,040 KB |
testcase_34 | AC | 243 ms
75,596 KB |
testcase_35 | AC | 242 ms
75,876 KB |
testcase_36 | AC | 39 ms
52,464 KB |
testcase_37 | AC | 39 ms
53,156 KB |
testcase_38 | AC | 51 ms
72,144 KB |
ソースコード
mod = 1000000007 eps = 10 ** -9 def main(): import sys input = sys.stdin.readline N, D = map(int, input().split()) P = [] Q = [] for _ in range(N): p, q = map(int, input().split()) P.append(p) Q.append(q) ok = -10 ** 9 ng = 0 mid = (ok + ng) // 2 while ng - ok > 1: prev = -1 cur = 0 flg = 1 for d in range(D-2): best = -10 ** 9 best_i = [] for i in range(N): if cur - P[i] < mid: continue if i == prev: continue cur_new = cur - P[i] + Q[i] if cur_new > best: best_i = [i] best = cur_new elif cur_new == best: best_i.append(i) if not best_i: flg = 0 break if len(best_i) > 1: prev = -1 else: prev = best_i[0] cur = best flg2 = 0 for i in range(N): if i == prev: continue if cur - P[i] < mid: continue cur_new_i = cur - P[i] + Q[i] for j in range(N): if j == i: continue if cur_new_i - P[j] >= mid: flg2 = 1 if flg2 == 0: flg = 0 if flg == 0: ng = mid else: ok = mid mid = (ok + ng) // 2 print(ok) if __name__ == '__main__': main()