結果
問題 | No.472 平均順位 |
ユーザー | tenten |
提出日時 | 2020-09-11 12:58:15 |
言語 | Java21 (openjdk 21) |
結果 |
MLE
|
実行時間 | - |
コード長 | 1,004 bytes |
コンパイル時間 | 1,838 ms |
コンパイル使用メモリ | 73,344 KB |
実行使用メモリ | 452,488 KB |
最終ジャッジ日時 | 2023-08-26 18:58:26 |
合計ジャッジ時間 | 10,844 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 105 ms
53,916 KB |
testcase_01 | AC | 106 ms
55,808 KB |
testcase_02 | AC | 107 ms
56,100 KB |
testcase_03 | AC | 114 ms
55,748 KB |
testcase_04 | AC | 131 ms
55,964 KB |
testcase_05 | AC | 112 ms
55,716 KB |
testcase_06 | AC | 124 ms
55,756 KB |
testcase_07 | AC | 140 ms
56,196 KB |
testcase_08 | AC | 202 ms
58,480 KB |
testcase_09 | AC | 271 ms
68,664 KB |
testcase_10 | AC | 259 ms
66,212 KB |
testcase_11 | AC | 430 ms
94,680 KB |
testcase_12 | AC | 390 ms
89,808 KB |
testcase_13 | AC | 616 ms
137,724 KB |
testcase_14 | MLE | - |
testcase_15 | AC | 591 ms
135,624 KB |
testcase_16 | MLE | - |
testcase_17 | MLE | - |
testcase_18 | AC | 347 ms
84,520 KB |
testcase_19 | AC | 525 ms
112,392 KB |
ソースコード
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[n + 1][p + 1]; for (int[] arr : dp) { Arrays.fill(arr, Integer.MAX_VALUE / 2); } dp[0][0] = 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); j >= 0; j--) { dp[i][j] = Math.min(dp[i][j], dp[i - 1][j] + zero); if (j - 1 >= 0) { dp[i][j] = Math.min(dp[i][j], dp[i - 1][j - 1] + one); } if (j - 2 >= 0) { dp[i][j] = Math.min(dp[i][j], dp[i - 1][j - 2] + two); } if (j - 3 >= 0) { dp[i][j] = Math.min(dp[i][j], dp[i - 1][j - 3] + 1); } } } System.out.println(dp[n][p] / (double)n); } }