結果

問題 No.472 平均順位
ユーザー uafr_csuafr_cs
提出日時 2017-11-08 19:19:37
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,278 ms / 2,000 ms
コード長 1,099 bytes
コンパイル時間 2,157 ms
コンパイル使用メモリ 78,864 KB
実行使用メモリ 70,344 KB
最終ジャッジ日時 2024-05-03 07:50:56
合計ジャッジ時間 11,771 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 136 ms
54,092 KB
testcase_01 AC 135 ms
53,944 KB
testcase_02 AC 139 ms
54,132 KB
testcase_03 AC 133 ms
54,196 KB
testcase_04 AC 165 ms
54,472 KB
testcase_05 AC 140 ms
53,952 KB
testcase_06 AC 149 ms
54,324 KB
testcase_07 AC 216 ms
54,472 KB
testcase_08 AC 250 ms
55,864 KB
testcase_09 AC 279 ms
57,852 KB
testcase_10 AC 307 ms
58,432 KB
testcase_11 AC 375 ms
58,800 KB
testcase_12 AC 325 ms
58,532 KB
testcase_13 AC 625 ms
59,108 KB
testcase_14 AC 1,115 ms
70,344 KB
testcase_15 AC 619 ms
59,024 KB
testcase_16 AC 1,184 ms
70,116 KB
testcase_17 AC 1,278 ms
69,944 KB
testcase_18 AC 308 ms
59,032 KB
testcase_19 AC 430 ms
58,744 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		final int P = sc.nextInt();
		
		long[] DP = new long[P + 1];
		long[] nextDP = new long[P + 1];
		
		final long INF = Long.MAX_VALUE / 2 - 1;
		for(int i = 0; i < N; i++){
			Arrays.fill(nextDP, INF);
			
			final int fst = sc.nextInt();
			final int snd = sc.nextInt();
			final int thd = sc.nextInt();
			
			for(int p = 0; p <= P; p++){
				nextDP[p] = Math.min(nextDP[p], DP[p] + fst);
			}
			for(int p = 0; p <= P - 1; p++){
				nextDP[p + 1] = Math.min(nextDP[p + 1], DP[p] + snd);
			}
			for(int p = 0; p <= P - 2; p++){
				nextDP[p + 2] = Math.min(nextDP[p + 2], DP[p] + thd);
			}
			for(int p = 0; p <= P - 3; p++){
				nextDP[p + 3] = Math.min(nextDP[p + 3], DP[p] + 1);
			}
			
			//System.out.println(Arrays.toString(nextDP));
			{
				long[] tmp = DP;
				DP = nextDP;
				nextDP = tmp;
			}
		}
		
		
		System.out.printf("%.08f\n", DP[P] / (double)(N));
	}
}
0