結果

問題 No.54 Happy Hallowe'en
ユーザー yuki2006yuki2006
提出日時 2014-10-30 21:23:44
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,072 bytes
コンパイル時間 3,235 ms
コンパイル使用メモリ 79,028 KB
実行使用メモリ 62,220 KB
最終ジャッジ日時 2023-08-28 23:29:16
合計ジャッジ時間 8,641 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
56,164 KB
testcase_01 AC 120 ms
56,316 KB
testcase_02 AC 118 ms
56,304 KB
testcase_03 AC 116 ms
56,120 KB
testcase_04 AC 304 ms
60,324 KB
testcase_05 AC 335 ms
60,600 KB
testcase_06 AC 371 ms
60,900 KB
testcase_07 AC 377 ms
60,644 KB
testcase_08 AC 433 ms
60,192 KB
testcase_09 AC 457 ms
60,508 KB
testcase_10 AC 118 ms
56,472 KB
testcase_11 AC 118 ms
56,256 KB
testcase_12 AC 398 ms
62,220 KB
testcase_13 AC 443 ms
60,744 KB
testcase_14 AC 118 ms
56,092 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 128 ms
56,452 KB
testcase_18 AC 129 ms
56,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Scanner;

public class Yuki054 {
    public static void main(String[] args) {
        Yuki054 hoge = new Yuki054();
    }

    Yuki054() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int[] datas = new int[N];
        for (int i = 0; i < N; i++) {
            int V = scanner.nextInt();
            int T = scanner.nextInt();
            datas[i] = T * 20000 + V;
        }
        Arrays.sort(datas);
        int[] dp = new int[100001];
        Arrays.fill(dp, -1);
        dp[0] = 0;
        for (int i = 0; i < N; i++) {
            int V = datas[i] % 20000;
            int T = datas[i] / 20000;
            for (int j = T - 1; j >= 0; j--) {
                if (dp[j] != -1) {
                    int K = Math.min(j + V, 10000);
                    dp[K] = Math.max(dp[K], dp[j] + V);
                }
            }
        }
        Arrays.sort(dp);
        System.out.println(dp[dp.length - 1]);
    }

}
0