結果

問題 No.1676 Coin Trade (Single)
ユーザー merlinmerlin
提出日時 2021-09-10 22:58:02
言語 Java19
(openjdk 21)
結果
AC  
実行時間 361 ms / 2,000 ms
コード長 936 bytes
コンパイル時間 4,001 ms
コンパイル使用メモリ 75,148 KB
実行使用メモリ 57,964 KB
最終ジャッジ日時 2023-09-02 20:38:23
合計ジャッジ時間 11,154 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
51,228 KB
testcase_01 AC 43 ms
49,164 KB
testcase_02 AC 45 ms
49,228 KB
testcase_03 AC 339 ms
55,876 KB
testcase_04 AC 326 ms
57,680 KB
testcase_05 AC 298 ms
57,908 KB
testcase_06 AC 308 ms
57,888 KB
testcase_07 AC 274 ms
57,964 KB
testcase_08 AC 181 ms
55,936 KB
testcase_09 AC 268 ms
57,492 KB
testcase_10 AC 281 ms
57,908 KB
testcase_11 AC 327 ms
57,364 KB
testcase_12 AC 211 ms
55,916 KB
testcase_13 AC 45 ms
49,416 KB
testcase_14 AC 45 ms
49,276 KB
testcase_15 AC 45 ms
49,940 KB
testcase_16 AC 45 ms
49,708 KB
testcase_17 AC 44 ms
49,172 KB
testcase_18 AC 44 ms
51,384 KB
testcase_19 AC 45 ms
47,888 KB
testcase_20 AC 45 ms
49,248 KB
testcase_21 AC 45 ms
49,156 KB
testcase_22 AC 45 ms
49,508 KB
testcase_23 AC 45 ms
49,260 KB
testcase_24 AC 44 ms
49,952 KB
testcase_25 AC 44 ms
49,368 KB
testcase_26 AC 44 ms
49,364 KB
testcase_27 AC 45 ms
49,236 KB
testcase_28 AC 45 ms
49,200 KB
testcase_29 AC 45 ms
49,236 KB
testcase_30 AC 44 ms
49,188 KB
testcase_31 AC 44 ms
49,424 KB
testcase_32 AC 45 ms
49,236 KB
testcase_33 AC 344 ms
57,592 KB
testcase_34 AC 340 ms
57,392 KB
testcase_35 AC 361 ms
57,676 KB
testcase_36 AC 357 ms
57,336 KB
testcase_37 AC 342 ms
57,608 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb=new StringBuilder();
        String s[]=bu.readLine().split(" ");
        int n=Integer.parseInt(s[0]),k=Integer.parseInt(s[1]);

        int i,b[]=new int[n];
        long dp[]=new long[n];
        for(i=0;i<n;i++)
        {
            s=bu.readLine().split(" ");
            int c=Integer.parseInt(s[0]),m=Integer.parseInt(s[1]);
            b[i]=c;
            if(i>0) dp[i]=dp[i-1];

            int j,x;
            s=bu.readLine().split(" ");
            for(j=0;j<m;j++)
            {
                x=Integer.parseInt(s[j])-1;
                dp[i]=Math.max(dp[x]+c-b[x],dp[i]);
            }
            //System.out.println(dp[i][0]+" "+dp[i][1]);
        }
        System.out.println(dp[n-1]);
    }
}
0