結果

問題 No.1676 Coin Trade (Single)
ユーザー ygd.ygd.
提出日時 2021-09-12 18:22:21
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 696 bytes
コンパイル時間 279 ms
コンパイル使用メモリ 87,124 KB
実行使用メモリ 93,588 KB
最終ジャッジ日時 2023-09-06 15:09:03
合計ジャッジ時間 7,199 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
71,392 KB
testcase_01 AC 68 ms
70,928 KB
testcase_02 AC 67 ms
71,276 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 124 ms
83,176 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 63 ms
71,276 KB
testcase_14 WA -
testcase_15 AC 65 ms
71,392 KB
testcase_16 WA -
testcase_17 AC 68 ms
71,508 KB
testcase_18 AC 67 ms
71,156 KB
testcase_19 WA -
testcase_20 AC 68 ms
70,940 KB
testcase_21 AC 68 ms
71,512 KB
testcase_22 WA -
testcase_23 AC 69 ms
71,128 KB
testcase_24 AC 66 ms
71,192 KB
testcase_25 AC 68 ms
71,200 KB
testcase_26 AC 68 ms
71,416 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 67 ms
70,964 KB
testcase_30 AC 65 ms
71,392 KB
testcase_31 AC 67 ms
71,388 KB
testcase_32 AC 67 ms
71,240 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 162 ms
93,252 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]) #何もしない
        for pre in RG[i]:
            if 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