結果

問題 No.1715 Dinner 2
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2021-10-23 12:02:28
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 659 bytes
コンパイル時間 209 ms
コンパイル使用メモリ 81,656 KB
実行使用メモリ 76,800 KB
最終ジャッジ日時 2023-10-25 07:54:53
合計ジャッジ時間 11,790 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,468 KB
testcase_01 WA -
testcase_02 AC 54 ms
63,880 KB
testcase_03 AC 40 ms
53,468 KB
testcase_04 AC 47 ms
61,664 KB
testcase_05 WA -
testcase_06 AC 40 ms
53,468 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 39 ms
53,468 KB
testcase_10 WA -
testcase_11 AC 733 ms
76,800 KB
testcase_12 AC 586 ms
76,616 KB
testcase_13 AC 510 ms
76,700 KB
testcase_14 AC 613 ms
76,480 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 401 ms
76,380 KB
testcase_18 AC 117 ms
76,284 KB
testcase_19 AC 124 ms
76,632 KB
testcase_20 AC 114 ms
76,276 KB
testcase_21 AC 95 ms
75,720 KB
testcase_22 AC 114 ms
76,260 KB
testcase_23 AC 122 ms
76,524 KB
testcase_24 AC 114 ms
76,236 KB
testcase_25 AC 178 ms
76,280 KB
testcase_26 AC 148 ms
76,312 KB
testcase_27 AC 156 ms
76,020 KB
testcase_28 AC 159 ms
76,232 KB
testcase_29 AC 172 ms
76,204 KB
testcase_30 AC 173 ms
76,236 KB
testcase_31 WA -
testcase_32 AC 876 ms
76,740 KB
testcase_33 AC 870 ms
76,732 KB
testcase_34 AC 868 ms
76,788 KB
testcase_35 AC 907 ms
76,712 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

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)
    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-1],ndp[j])
            rdp[n-1-j] = max(ndp[n-1-j],ndp[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