結果
問題 | No.472 平均順位 |
ユーザー |
![]() |
提出日時 | 2020-01-08 17:10:37 |
言語 | Java (openjdk 23) |
結果 |
MLE
|
実行時間 | - |
コード長 | 1,342 bytes |
コンパイル時間 | 2,735 ms |
コンパイル使用メモリ | 77,612 KB |
実行使用メモリ | 439,656 KB |
最終ジャッジ日時 | 2024-11-23 02:55:41 |
合計ジャッジ時間 | 16,008 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 MLE * 2 |
other | AC * 12 TLE * 3 MLE * 1 |
ソースコード
import java.util.*;import java.io.*;public class Main {static int[][] dp;static int[][] contests;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]);dp = new int[n + 1][p + 1];contests = new int[n + 1][3];for (int i = 1; i <= n; i++) {String[] line = br.readLine().split(" ", 3);for (int j = 0; j < 3; j++) {contests[i][j] = Integer.parseInt(line[j]);}Arrays.fill(dp[i], Integer.MAX_VALUE);}System.out.println(dfw(n, 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] != Integer.MAX_VALUE) {return dp[idx][count];}for (int i = 0; i < 3; i++) {dp[idx][count] = Math.min(dp[idx][count], dfw(idx - 1, count - i) + contests[idx][i]);}dp[idx][count] = Math.min(dp[idx][count], dfw(idx - 1, count - 3) + 1);return dp[idx][count];}}