結果

問題 No.1676 Coin Trade (Single)
ユーザー ygd.ygd.
提出日時 2021-09-12 18:28:15
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 735 bytes
コンパイル時間 304 ms
コンパイル使用メモリ 86,904 KB
実行使用メモリ 93,532 KB
最終ジャッジ日時 2023-09-06 15:15:29
合計ジャッジ時間 6,769 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,284 KB
testcase_01 AC 72 ms
71,312 KB
testcase_02 AC 69 ms
71,296 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 137 ms
83,320 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 70 ms
71,280 KB
testcase_14 WA -
testcase_15 AC 71 ms
71,316 KB
testcase_16 WA -
testcase_17 AC 70 ms
71,060 KB
testcase_18 AC 70 ms
71,280 KB
testcase_19 WA -
testcase_20 AC 69 ms
71,344 KB
testcase_21 AC 71 ms
71,252 KB
testcase_22 WA -
testcase_23 AC 70 ms
71,296 KB
testcase_24 AC 71 ms
71,452 KB
testcase_25 AC 70 ms
71,060 KB
testcase_26 AC 72 ms
71,196 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 72 ms
71,280 KB
testcase_30 AC 72 ms
71,428 KB
testcase_31 AC 71 ms
71,624 KB
testcase_32 AC 72 ms
71,440 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 187 ms
93,224 KB
testcase_36 WA -
testcase_37 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.buffer.readline

def main():
    N,K = map(int,input().split())
    A = []; M = []
    RG = []
    for i in range(N):
        a,m = map(int,input().split())
        A.append(a)
        M.append(m)
        B = list(map(int,input().split()))
        B = [b-1 for b in B] #0index
        RG.append(B)

    dp = [0]*(N+1)
    for i in range(N):
        dp[i+1] = max(dp[i+1],dp[i]) #何もしない
        #print(A[i],RG[i])
        for pre in RG[i]:
            if pre < i and A[pre] < A[i]: #前のほうが安いなら。
                dif = A[i] - A[pre]
                dp[i+1] = max(dp[i+1], dp[pre] + dif)
    #print(dp)
    ans = dp[N]
    print(ans)

    
    
if __name__ == '__main__':
    main()
0