結果

問題 No.1715 Dinner 2
ユーザー 👑 H20H20
提出日時 2021-10-22 22:20:20
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 979 bytes
コンパイル時間 1,016 ms
コンパイル使用メモリ 81,404 KB
実行使用メモリ 87,200 KB
最終ジャッジ日時 2023-10-24 13:35:14
合計ジャッジ時間 3,928 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 38 ms
53,204 KB
testcase_02 AC 38 ms
53,204 KB
testcase_03 AC 36 ms
53,204 KB
testcase_04 AC 36 ms
53,204 KB
testcase_05 WA -
testcase_06 AC 36 ms
53,204 KB
testcase_07 WA -
testcase_08 AC 36 ms
53,204 KB
testcase_09 AC 35 ms
53,204 KB
testcase_10 WA -
testcase_11 AC 99 ms
87,200 KB
testcase_12 AC 97 ms
85,732 KB
testcase_13 AC 94 ms
84,216 KB
testcase_14 AC 94 ms
85,696 KB
testcase_15 AC 98 ms
85,916 KB
testcase_16 AC 93 ms
85,396 KB
testcase_17 AC 78 ms
73,736 KB
testcase_18 WA -
testcase_19 AC 54 ms
66,276 KB
testcase_20 AC 55 ms
66,276 KB
testcase_21 AC 47 ms
62,092 KB
testcase_22 WA -
testcase_23 AC 55 ms
68,396 KB
testcase_24 AC 58 ms
64,204 KB
testcase_25 AC 55 ms
68,376 KB
testcase_26 AC 55 ms
66,328 KB
testcase_27 AC 58 ms
68,400 KB
testcase_28 AC 57 ms
68,388 KB
testcase_29 AC 54 ms
66,324 KB
testcase_30 AC 56 ms
68,388 KB
testcase_31 AC 56 ms
68,376 KB
testcase_32 AC 106 ms
85,848 KB
testcase_33 AC 105 ms
85,836 KB
testcase_34 AC 107 ms
85,852 KB
testcase_35 AC 106 ms
85,848 KB
testcase_36 AC 36 ms
53,208 KB
testcase_37 WA -
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

N,D=map(int, input().split())
PQ = [list(map(int, input().split())) for _ in range(N)]
DP = [[0]*N for _ in range(2*D)]
maxv = -10**12
maxi = -1
nextv = -10**12
for i in range(N):
    DP[0][i]=-PQ[i][0]
    DP[1][i]=PQ[i][1]-PQ[i][0]
    if DP[1][i]>=maxv:
        nextv = maxv
        maxv = DP[1][i]
        maxi = i
    else:
        nextv = max(nextv,DP[1][i])
for d in range(2,2*D):
    if d%2==0:
        nextmax = -10**12
        for i in range(N):
            if maxi==i:
                DP[d][i]=-PQ[i][0]+nextv
            else:
                DP[d][i]=-PQ[i][0]+maxv
    else:
        maxv = -10**12
        maxi = -1
        nextv = -10**12
        for i in range(N):
            DP[d][i]=PQ[i][1]-DP[d-1][i]
            if DP[d][i]>=maxv:
                nextv = maxv
                maxv = DP[d][i]
                maxi = i
            else:
                nextv = max(nextv,DP[d][i])
ans = 10**12
for i in range(0,2*D,2):
    ans = min(ans,max(DP[i]))
print(ans)
0