結果
| 問題 |
No.472 平均順位
|
| コンテスト | |
| ユーザー |
htensai
|
| 提出日時 | 2020-01-08 17:24:32 |
| 言語 | Java (openjdk 23) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 1,456 bytes |
| コンパイル時間 | 2,176 ms |
| コンパイル使用メモリ | 77,780 KB |
| 実行使用メモリ | 645,244 KB |
| 最終ジャッジ日時 | 2024-11-23 02:57:14 |
| 合計ジャッジ時間 | 30,599 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 MLE * 2 |
| other | AC * 7 TLE * 6 MLE * 3 |
ソースコード
import java.util.*;
import java.io.*;
public class Main {
static HashMap<Integer, Integer>[] 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 HashMap[n + 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]);
}
dp[i] = new HashMap<Integer, Integer>();
}
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].containsKey(count)) {
return dp[idx].get(count);
}
int ans = Integer.MAX_VALUE;
for (int i = 0; i < 3; i++) {
if (count - i > (idx - 1) * 3) {
continue;
}
ans = Math.min(ans, dfw(idx - 1, count - i) + contests[idx][i]);
}
ans = Math.min(ans, dfw(idx - 1, count - 3) + 1);
dp[idx].put(count, ans);
return ans;
}
}
htensai