結果
| 問題 |
No.472 平均順位
|
| コンテスト | |
| ユーザー |
tenten
|
| 提出日時 | 2020-09-11 12:58:15 |
| 言語 | Java (openjdk 23) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 1,004 bytes |
| コンパイル時間 | 2,894 ms |
| コンパイル使用メモリ | 77,016 KB |
| 実行使用メモリ | 368,612 KB |
| 最終ジャッジ日時 | 2024-12-25 20:03:25 |
| 合計ジャッジ時間 | 16,646 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 13 MLE * 3 |
ソースコード
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);
}
}
tenten