結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 37 ms
53,324 KB
testcase_02 AC 37 ms
53,324 KB
testcase_03 AC 35 ms
53,324 KB
testcase_04 AC 36 ms
53,324 KB
testcase_05 WA -
testcase_06 AC 36 ms
53,324 KB
testcase_07 WA -
testcase_08 AC 36 ms
53,324 KB
testcase_09 AC 35 ms
53,324 KB
testcase_10 WA -
testcase_11 AC 98 ms
87,312 KB
testcase_12 AC 96 ms
85,860 KB
testcase_13 AC 93 ms
84,472 KB
testcase_14 AC 95 ms
85,964 KB
testcase_15 AC 97 ms
86,056 KB
testcase_16 AC 91 ms
85,524 KB
testcase_17 AC 75 ms
74,132 KB
testcase_18 WA -
testcase_19 AC 55 ms
66,416 KB
testcase_20 AC 55 ms
66,420 KB
testcase_21 AC 49 ms
64,272 KB
testcase_22 WA -
testcase_23 AC 56 ms
68,528 KB
testcase_24 AC 56 ms
66,420 KB
testcase_25 AC 57 ms
68,524 KB
testcase_26 AC 56 ms
68,524 KB
testcase_27 AC 58 ms
68,524 KB
testcase_28 AC 57 ms
68,524 KB
testcase_29 AC 58 ms
68,524 KB
testcase_30 AC 58 ms
68,524 KB
testcase_31 AC 57 ms
68,524 KB
testcase_32 AC 107 ms
85,964 KB
testcase_33 AC 106 ms
85,956 KB
testcase_34 AC 107 ms
85,964 KB
testcase_35 AC 106 ms
85,956 KB
testcase_36 AC 36 ms
53,324 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)]
maxv1 = -10**12
maxv2 = -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[0][i]>maxv1:
        maxv1 = DP[0][i]
        maxi = i
        nextv = maxv2
        maxv2 = DP[1][i]

    else:
        nextv = max(nextv,DP[1][i])
for d in range(2,2*D):
    if d%2==0:
        for i in range(N):
            if maxi==i:
                DP[d][i]=-PQ[i][0]+nextv
            else:
                DP[d][i]=-PQ[i][0]+maxv2
    else:
        maxv1 = -10**12
        maxv2 = -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-1][i]>maxv1:
                maxv1 = DP[d-1][i]
                maxi = i
                nextv = maxv2
                maxv2 = DP[d][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