結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,376 KB
testcase_01 WA -
testcase_02 AC 51 ms
63,816 KB
testcase_03 AC 38 ms
53,412 KB
testcase_04 AC 45 ms
61,604 KB
testcase_05 AC 45 ms
61,448 KB
testcase_06 AC 39 ms
53,412 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 38 ms
53,412 KB
testcase_10 WA -
testcase_11 AC 731 ms
76,768 KB
testcase_12 AC 575 ms
76,572 KB
testcase_13 AC 509 ms
76,656 KB
testcase_14 AC 604 ms
76,444 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 393 ms
76,348 KB
testcase_18 AC 112 ms
76,248 KB
testcase_19 AC 119 ms
76,600 KB
testcase_20 AC 109 ms
76,248 KB
testcase_21 AC 91 ms
75,680 KB
testcase_22 AC 112 ms
76,228 KB
testcase_23 AC 120 ms
76,496 KB
testcase_24 AC 110 ms
76,204 KB
testcase_25 AC 171 ms
76,248 KB
testcase_26 AC 142 ms
76,280 KB
testcase_27 AC 151 ms
75,992 KB
testcase_28 AC 154 ms
76,220 KB
testcase_29 AC 164 ms
76,112 KB
testcase_30 AC 168 ms
76,204 KB
testcase_31 WA -
testcase_32 AC 868 ms
76,732 KB
testcase_33 AC 858 ms
76,704 KB
testcase_34 AC 850 ms
76,760 KB
testcase_35 AC 901 ms
76,676 KB
testcase_36 AC 37 ms
53,412 KB
testcase_37 AC 37 ms
53,412 KB
testcase_38 AC 108 ms
75,696 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-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