結果
問題 |
No.472 平均順位
|
ユーザー |
![]() |
提出日時 | 2020-01-30 13:42:48 |
言語 | Java (openjdk 23) |
結果 |
MLE
|
実行時間 | - |
コード長 | 1,559 bytes |
コンパイル時間 | 2,140 ms |
コンパイル使用メモリ | 77,264 KB |
実行使用メモリ | 409,976 KB |
最終ジャッジ日時 | 2024-09-16 03:31:08 |
合計ジャッジ時間 | 8,345 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 13 MLE * 3 |
ソースコード
import java.util.*; import java.io.*; public class Main { static int[][] scores; static int[][] dp; public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] first = br.readLine().split(" ", 2); int n = Integer.parseInt(first[0]); int p = Integer.parseInt(first[1]); scores = new int[n][3]; for (int i = 0; i < n; i++) { String[] line = br.readLine().split(" ", 3); for (int j = 0; j < 3; j++) { scores[i][j] = Integer.parseInt(line[j]); } } dp = new int[n][p + 1]; System.out.println(dfw(n - 1, p) / (double)n); } static int dfw(int idx, int count) { if (count < 0) { return Integer.MAX_VALUE / 2; } if (idx < 0) { return 0; } if (dp[idx][count] != 0) { return dp[idx][count]; } int min = Integer.MAX_VALUE / 2; if (idx * 3 >= count) { min = Math.min(min, dfw(idx - 1, count) + scores[idx][0]); } if (idx * 3 >= count - 1) { min = Math.min(min, dfw(idx - 1, count - 1) + scores[idx][1]); } if (idx * 3 >= count - 2) { min = Math.min(min, dfw(idx - 1, count - 2) + scores[idx][2]); } if (idx * 3 >= count - 3) { min = Math.min(min, dfw(idx - 1, count - 3) + 1); } dp[idx][count] = min; return min; } }