結果

問題 No.472 平均順位
ユーザー htensaihtensai
提出日時 2020-01-08 17:10:37
言語 Java21
(openjdk 21)
結果
MLE  
実行時間 -
コード長 1,342 bytes
コンパイル時間 2,434 ms
コンパイル使用メモリ 74,140 KB
実行使用メモリ 370,488 KB
最終ジャッジ日時 2023-08-15 00:40:07
合計ジャッジ時間 10,714 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
49,424 KB
testcase_01 AC 47 ms
49,824 KB
testcase_02 AC 44 ms
49,432 KB
testcase_03 AC 52 ms
49,668 KB
testcase_04 AC 56 ms
49,844 KB
testcase_05 AC 50 ms
49,236 KB
testcase_06 AC 54 ms
49,412 KB
testcase_07 AC 73 ms
52,384 KB
testcase_08 AC 118 ms
55,092 KB
testcase_09 AC 180 ms
62,488 KB
testcase_10 AC 183 ms
58,444 KB
testcase_11 AC 341 ms
78,384 KB
testcase_12 AC 276 ms
55,788 KB
testcase_13 AC 772 ms
132,820 KB
testcase_14 MLE -
testcase_15 AC 915 ms
132,968 KB
testcase_16 TLE -
testcase_17 TLE -
testcase_18 AC 233 ms
69,860 KB
testcase_19 AC 475 ms
89,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    static int[][] dp;
    static int[][] contests;
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] first = br.readLine().split(" ", 2);
        int n = Integer.parseInt(first[0]);
        int p = Integer.parseInt(first[1]);
        dp = new int[n + 1][p + 1];
        contests = new int[n + 1][3];
        for (int i = 1; i <= n; i++) {
            String[] line = br.readLine().split(" ", 3);
            for (int j = 0; j < 3; j++) {
                contests[i][j] = Integer.parseInt(line[j]);
            }
            Arrays.fill(dp[i], Integer.MAX_VALUE);
        }
        System.out.println(dfw(n, p) / (double) n);
    }
    
    static int dfw(int idx, int count) {
        if (count < 0) {
            return Integer.MAX_VALUE / 2;
        }
        if (idx <= 0) {
            return 0;
        }
        if (dp[idx][count] != Integer.MAX_VALUE) {
            return dp[idx][count];
        }
        for (int i = 0; i < 3; i++) {
            dp[idx][count] = Math.min(dp[idx][count], dfw(idx - 1, count - i) + contests[idx][i]);
        }
        dp[idx][count] = Math.min(dp[idx][count], dfw(idx - 1, count - 3) + 1);
        return dp[idx][count];
    }
}
0