結果

問題 No.1715 Dinner 2
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2021-10-23 12:10:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 838 ms / 2,000 ms
コード長 669 bytes
コンパイル時間 174 ms
コンパイル使用メモリ 81,604 KB
実行使用メモリ 76,920 KB
最終ジャッジ日時 2023-10-25 08:02:30
合計ジャッジ時間 10,819 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,420 KB
testcase_01 AC 40 ms
53,420 KB
testcase_02 AC 53 ms
63,832 KB
testcase_03 AC 40 ms
53,420 KB
testcase_04 AC 47 ms
61,608 KB
testcase_05 AC 48 ms
61,448 KB
testcase_06 AC 40 ms
53,420 KB
testcase_07 AC 46 ms
59,552 KB
testcase_08 AC 47 ms
61,448 KB
testcase_09 AC 40 ms
53,420 KB
testcase_10 AC 46 ms
59,552 KB
testcase_11 AC 586 ms
76,464 KB
testcase_12 AC 592 ms
76,400 KB
testcase_13 AC 428 ms
76,436 KB
testcase_14 AC 582 ms
76,356 KB
testcase_15 AC 562 ms
76,656 KB
testcase_16 AC 448 ms
76,328 KB
testcase_17 AC 372 ms
76,292 KB
testcase_18 AC 116 ms
76,252 KB
testcase_19 AC 116 ms
75,840 KB
testcase_20 AC 111 ms
76,268 KB
testcase_21 AC 96 ms
75,664 KB
testcase_22 AC 111 ms
75,676 KB
testcase_23 AC 114 ms
75,812 KB
testcase_24 AC 110 ms
75,664 KB
testcase_25 AC 153 ms
76,108 KB
testcase_26 AC 137 ms
76,084 KB
testcase_27 AC 141 ms
75,916 KB
testcase_28 AC 144 ms
75,972 KB
testcase_29 AC 151 ms
75,896 KB
testcase_30 AC 154 ms
76,116 KB
testcase_31 AC 152 ms
76,056 KB
testcase_32 AC 788 ms
76,708 KB
testcase_33 AC 720 ms
76,920 KB
testcase_34 AC 734 ms
76,672 KB
testcase_35 AC 838 ms
76,824 KB
testcase_36 AC 40 ms
53,420 KB
testcase_37 AC 40 ms
53,420 KB
testcase_38 AC 102 ms
75,580 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,D = map(int,input().split())
PQ = [list(map(int,input().split())) for i in range(n)]
inf = 10**8
def search(x):
    ldp = [0]*(n+1)
    rdp = [0]*(n+1)
    ldp[-1] = rdp[-1] = -inf
    for i in range(D):
        ndp = [-inf]*(n+1)
        for j,(p,q) in enumerate(PQ):
            nex = max(ldp[j-1],rdp[j+1])
            if nex-p >= x:
                ndp[j] = nex-p+q
        for j in range(n):
            ldp[j] = max(ndp[j],ldp[j-1])
            rdp[n-1-j] = max(ndp[n-1-j],rdp[n-j])
    if rdp[0] != -inf:
        return True
    return False



l = -inf
r = 0

while r > l + 1:
    m = (r+l)//2

    if search(m):
        l = m
    else:
        r = m
print(l)
0