結果
問題 | No.472 平均順位 |
ユーザー | takeya_okino |
提出日時 | 2017-07-05 19:04:24 |
言語 | Java21 (openjdk 21) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,231 bytes |
コンパイル時間 | 2,707 ms |
コンパイル使用メモリ | 76,984 KB |
実行使用メモリ | 352,828 KB |
最終ジャッジ日時 | 2024-04-15 18:16:13 |
合計ジャッジ時間 | 12,759 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | RE | - |
testcase_01 | RE | - |
testcase_02 | RE | - |
testcase_03 | AC | 111 ms
40,024 KB |
testcase_04 | AC | 158 ms
41,732 KB |
testcase_05 | AC | 114 ms
40,384 KB |
testcase_06 | AC | 133 ms
41,536 KB |
testcase_07 | AC | 150 ms
41,924 KB |
testcase_08 | AC | 219 ms
45,656 KB |
testcase_09 | AC | 313 ms
51,996 KB |
testcase_10 | AC | 294 ms
51,284 KB |
testcase_11 | AC | 371 ms
76,040 KB |
testcase_12 | AC | 318 ms
67,612 KB |
testcase_13 | AC | 540 ms
120,340 KB |
testcase_14 | MLE | - |
testcase_15 | AC | 685 ms
120,340 KB |
testcase_16 | MLE | - |
testcase_17 | MLE | - |
testcase_18 | AC | 339 ms
60,408 KB |
testcase_19 | AC | 486 ms
78,132 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[] a = new int[N]; int[] b = new int[N]; int[] c = new int[N]; for(int i = 0; i < N; i++) { a[i] = sc.nextInt(); b[i] = sc.nextInt(); c[i] = sc.nextInt(); } // dp[i][j]はコンテストiまでで正解数がちょうどj問の場合の順位の和の最小値(有り得ない場合は0とする) int[][] dp = new int[N][P + 1]; dp[0][0] = a[0]; dp[0][1] = b[0]; dp[0][2] = c[0]; dp[0][3] = 1; for(int i = 1; i < N; i++) { for(int j = 0; j < P + 1; j++) { int min = Integer.MAX_VALUE; if(dp[i - 1][j] != 0) min = Math.min(min, a[i] + dp[i - 1][j]); if(j >= 1 && dp[i - 1][j - 1] != 0) min = Math.min(min, b[i] + dp[i - 1][j - 1]); if(j >= 2 && dp[i - 1][j - 2] != 0) min = Math.min(min, c[i] + dp[i - 1][j - 2]); if(j >= 3 && dp[i - 1][j - 3] != 0) min = Math.min(min, 1 + dp[i - 1][j - 3]); if(min == Integer.MAX_VALUE) min = 0; dp[i][j] = min; } } System.out.println((double)dp[N - 1][P] / (double)N); } }