結果

問題 No.472 平均順位
ユーザー htensaihtensai
提出日時 2019-11-19 11:09:51
言語 Java21
(openjdk 21)
結果
MLE  
実行時間 -
コード長 899 bytes
コンパイル時間 2,134 ms
コンパイル使用メモリ 77,776 KB
実行使用メモリ 369,256 KB
最終ジャッジ日時 2024-04-14 09:22:29
合計ジャッジ時間 13,151 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 134 ms
54,276 KB
testcase_01 AC 137 ms
54,380 KB
testcase_02 AC 138 ms
54,000 KB
testcase_03 AC 137 ms
54,120 KB
testcase_04 AC 167 ms
54,392 KB
testcase_05 AC 144 ms
54,476 KB
testcase_06 AC 159 ms
54,452 KB
testcase_07 AC 172 ms
54,284 KB
testcase_08 AC 226 ms
56,960 KB
testcase_09 AC 333 ms
65,252 KB
testcase_10 AC 333 ms
62,992 KB
testcase_11 AC 439 ms
87,532 KB
testcase_12 AC 415 ms
80,284 KB
testcase_13 AC 715 ms
134,244 KB
testcase_14 MLE -
testcase_15 AC 794 ms
134,608 KB
testcase_16 MLE -
testcase_17 MLE -
testcase_18 AC 380 ms
80,252 KB
testcase_19 AC 532 ms
105,692 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    static int[][] prises;
    static int[][] dp;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int p = sc.nextInt();
		prises = new int[3][n + 1];
		dp = new int[p + 1][n + 1];
		for (int i = 1; i <= n; i++) {
		    for (int j = 0; j < 3; j++) {
		        prises[j][i] = sc.nextInt();
		    }
		}
		double sum = dfw(p, n);
		System.out.println(sum / n);
	}
	
	static int dfw(int point, int idx) {
	    if (point < 0) {
	        return Integer.MAX_VALUE / 2 + 1;
	    }
	    if (idx == 0) {
	        return 0;
	    }
	    if (dp[point][idx] != 0) {
	        return dp[point][idx] ;
	    }
	    int min = dfw(point - 3, idx - 1) + 1;
	    for (int j = 0; j < 3; j++) {
	        min = Math.min(min, prises[j][idx] + dfw(point - j, idx - 1));
	    }
	    dp[point][idx] = min;
	    return min;
	}
}
0