結果
問題 | No.1715 Dinner 2 |
ユーザー | tamato |
提出日時 | 2021-10-22 22:06:29 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,010 bytes |
コンパイル時間 | 313 ms |
コンパイル使用メモリ | 82,520 KB |
実行使用メモリ | 75,276 KB |
最終ジャッジ日時 | 2024-09-23 05:37:22 |
合計ジャッジ時間 | 4,273 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 38 ms
54,048 KB |
testcase_01 | AC | 38 ms
52,816 KB |
testcase_02 | AC | 44 ms
60,976 KB |
testcase_03 | AC | 39 ms
54,300 KB |
testcase_04 | AC | 45 ms
59,792 KB |
testcase_05 | AC | 42 ms
59,780 KB |
testcase_06 | AC | 38 ms
53,016 KB |
testcase_07 | AC | 42 ms
59,660 KB |
testcase_08 | AC | 42 ms
59,140 KB |
testcase_09 | AC | 38 ms
52,832 KB |
testcase_10 | AC | 43 ms
60,684 KB |
testcase_11 | AC | 127 ms
69,932 KB |
testcase_12 | AC | 117 ms
70,056 KB |
testcase_13 | AC | 99 ms
67,440 KB |
testcase_14 | AC | 109 ms
68,636 KB |
testcase_15 | AC | 116 ms
71,312 KB |
testcase_16 | AC | 114 ms
70,744 KB |
testcase_17 | AC | 94 ms
71,032 KB |
testcase_18 | AC | 51 ms
65,524 KB |
testcase_19 | AC | 50 ms
64,640 KB |
testcase_20 | AC | 49 ms
63,876 KB |
testcase_21 | AC | 46 ms
62,804 KB |
testcase_22 | AC | 49 ms
65,332 KB |
testcase_23 | AC | 53 ms
67,984 KB |
testcase_24 | AC | 51 ms
66,352 KB |
testcase_25 | AC | 58 ms
68,052 KB |
testcase_26 | AC | 56 ms
67,492 KB |
testcase_27 | AC | 55 ms
66,040 KB |
testcase_28 | AC | 57 ms
66,112 KB |
testcase_29 | AC | 57 ms
65,924 KB |
testcase_30 | AC | 57 ms
66,712 KB |
testcase_31 | AC | 58 ms
66,536 KB |
testcase_32 | AC | 146 ms
73,224 KB |
testcase_33 | AC | 147 ms
71,960 KB |
testcase_34 | AC | 164 ms
75,276 KB |
testcase_35 | AC | 155 ms
72,444 KB |
testcase_36 | AC | 37 ms
53,152 KB |
testcase_37 | WA | - |
testcase_38 | WA | - |
ソースコード
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): i_best = -1 cur_best = -10 ** 9 for i in range(N): if cur - P[i] < mid: continue if prev == i: continue cur_new = cur - P[i] + Q[i] if cur_new < mid: continue if cur_new > cur_best: cur_best = cur_new i_best = i if i_best == -1: flg = 0 break else: if d == 0: i_best_first = i_best prev = i_best cur = cur_best if flg == 0: prev = i_best_first cur = 0 flg = 1 for d in range(D): i_best = -1 cur_best = -10 ** 9 for i in range(N): if cur - P[i] < mid: continue if prev == i: continue cur_new = cur - P[i] + Q[i] if cur_new < mid: continue if cur_new > cur_best: cur_best = cur_new i_best = i if i_best == -1: flg = 0 break prev = i_best cur = cur_best if flg: ok = mid else: ng = mid else: ok = mid mid = (ok + ng) // 2 print(ok) if __name__ == '__main__': main()