結果

問題 No.472 平均順位
ユーザー htensai
提出日時 2019-11-19 11:09:51
言語 Java
(openjdk 23)
結果
MLE  
実行時間 -
コード長 899 bytes
コンパイル時間 1,795 ms
コンパイル使用メモリ 77,100 KB
実行使用メモリ 368,388 KB
最終ジャッジ日時 2024-10-03 06:23:33
合計ジャッジ時間 10,795 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 13 MLE * 3
権限があれば一括ダウンロードができます

ソースコード

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