結果
問題 | No.472 平均順位 |
ユーザー |
![]() |
提出日時 | 2021-11-11 18:19:45 |
言語 | Java (openjdk 23) |
結果 |
MLE
|
実行時間 | - |
コード長 | 1,870 bytes |
コンパイル時間 | 2,466 ms |
コンパイル使用メモリ | 77,540 KB |
実行使用メモリ | 431,600 KB |
最終ジャッジ日時 | 2024-11-23 03:41:37 |
合計ジャッジ時間 | 8,849 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 13 MLE * 3 |
ソースコード
import java.util.*;import java.io.*;public class Main {static int[][] points;static int[][] dp;public static void main(String[] args) throws Exception {Scanner sc = new Scanner();int n = sc.nextInt();int p = sc.nextInt();points = new int[n][4];for (int i = 0; i < n; i++) {for (int j = 0; j < 3; j++) {points[i][j] = sc.nextInt();}points[i][3] = 1;}dp = new int[n][p + 1];double all = dfw(n - 1, p);System.out.println(all / n);}static int dfw(int idx, int p) {if (p < 0) {return Integer.MAX_VALUE / 2;}if (idx < 0) {return 0;}if ((idx + 1) * 3 <= p) {return idx + 1;}if (dp[idx][p] == 0) {dp[idx][p] = Integer.MAX_VALUE;for (int i = 0; i < 4; i++) {dp[idx][p] = Math.min(dp[idx][p], dfw(idx - 1, p - i) + points[idx][i]);}}return dp[idx][p];}}class Scanner {BufferedReader br = new BufferedReader(new InputStreamReader(System.in));StringTokenizer st = new StringTokenizer("");public Scanner() throws Exception {}public int nextInt() throws Exception {return Integer.parseInt(next());}public long nextLong() throws Exception {return Long.parseLong(next());}public double nextDouble() throws Exception {return Double.parseDouble(next());}public String nextLine() throws Exception {return br.readLine();}public String next() throws Exception {if (!st.hasMoreTokens()) {st = new StringTokenizer(br.readLine());}return st.nextToken();}}