結果

問題 No.472 平均順位
ユーザー tentententen
提出日時 2020-09-11 16:00:11
言語 Java21
(openjdk 21)
結果
AC  
実行時間 640 ms / 2,000 ms
コード長 654 bytes
コンパイル時間 2,617 ms
コンパイル使用メモリ 71,256 KB
実行使用メモリ 67,084 KB
最終ジャッジ日時 2023-08-26 23:04:18
合計ジャッジ時間 9,700 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
56,252 KB
testcase_01 AC 126 ms
56,344 KB
testcase_02 AC 125 ms
55,968 KB
testcase_03 AC 126 ms
55,720 KB
testcase_04 AC 156 ms
55,624 KB
testcase_05 AC 129 ms
55,976 KB
testcase_06 AC 141 ms
55,976 KB
testcase_07 AC 156 ms
55,704 KB
testcase_08 AC 204 ms
56,416 KB
testcase_09 AC 246 ms
60,164 KB
testcase_10 AC 245 ms
59,784 KB
testcase_11 AC 373 ms
65,220 KB
testcase_12 AC 325 ms
60,208 KB
testcase_13 AC 498 ms
66,576 KB
testcase_14 AC 591 ms
66,000 KB
testcase_15 AC 526 ms
64,972 KB
testcase_16 AC 597 ms
66,896 KB
testcase_17 AC 640 ms
67,084 KB
testcase_18 AC 273 ms
61,640 KB
testcase_19 AC 492 ms
63,492 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
    	int p = sc.nextInt();
    	int[] dp = new int[p + 5];
    	Arrays.fill(dp, Integer.MAX_VALUE / 2);
    	dp[3] = 0;
    	for (int i = 1; i <= n; i++) {
    	    int zero = sc.nextInt();
    	    int one = sc.nextInt();
    	    int two = sc.nextInt();
    	    for (int j = Math.min(p, i * 3) + 3; j >= 3; j--) {
    	        dp[j] = Math.min(Math.min(dp[j] + zero, dp[j - 1] + one), Math.min(dp[j - 2] + two, dp[j - 3] + 1));
    	    }
    	}
    	System.out.println(dp[p + 3] / (double)n);
	}
}
0