結果

問題 No.1715 Dinner 2
ユーザー 👑 H20H20
提出日時 2021-10-22 22:25:38
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 951 bytes
コンパイル時間 574 ms
コンパイル使用メモリ 81,664 KB
実行使用メモリ 87,272 KB
最終ジャッジ日時 2023-10-24 13:42:04
合計ジャッジ時間 4,727 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 42 ms
53,288 KB
testcase_02 AC 41 ms
53,288 KB
testcase_03 AC 41 ms
53,288 KB
testcase_04 AC 39 ms
53,288 KB
testcase_05 WA -
testcase_06 AC 39 ms
53,288 KB
testcase_07 WA -
testcase_08 AC 38 ms
53,288 KB
testcase_09 AC 38 ms
53,288 KB
testcase_10 WA -
testcase_11 AC 105 ms
87,272 KB
testcase_12 AC 98 ms
85,804 KB
testcase_13 AC 95 ms
84,304 KB
testcase_14 AC 98 ms
85,784 KB
testcase_15 AC 99 ms
85,988 KB
testcase_16 AC 96 ms
85,476 KB
testcase_17 AC 76 ms
73,828 KB
testcase_18 WA -
testcase_19 AC 57 ms
66,368 KB
testcase_20 AC 54 ms
64,304 KB
testcase_21 AC 49 ms
62,180 KB
testcase_22 WA -
testcase_23 AC 59 ms
68,488 KB
testcase_24 AC 54 ms
64,304 KB
testcase_25 AC 58 ms
68,464 KB
testcase_26 AC 58 ms
66,428 KB
testcase_27 AC 60 ms
68,484 KB
testcase_28 AC 60 ms
68,476 KB
testcase_29 AC 59 ms
68,476 KB
testcase_30 AC 58 ms
68,468 KB
testcase_31 AC 57 ms
66,416 KB
testcase_32 AC 108 ms
85,936 KB
testcase_33 AC 108 ms
85,916 KB
testcase_34 AC 109 ms
85,928 KB
testcase_35 AC 108 ms
85,936 KB
testcase_36 AC 37 ms
53,292 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:
        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