結果
| 問題 |
No.472 平均順位
|
| コンテスト | |
| ユーザー |
tenten
|
| 提出日時 | 2021-11-11 18:22:46 |
| 言語 | Java (openjdk 23) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 1,972 bytes |
| コンパイル時間 | 2,558 ms |
| コンパイル使用メモリ | 78,340 KB |
| 実行使用メモリ | 505,032 KB |
| 最終ジャッジ日時 | 2024-11-23 03:48:26 |
| 合計ジャッジ時間 | 28,551 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 MLE * 2 |
| other | AC * 7 TLE * 7 MLE * 2 |
ソースコード
import java.util.*;
import java.io.*;
public class Main {
static int[][] points;
static ArrayList<HashMap<Integer, Integer>> dp = new ArrayList<>();
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.add(new HashMap<>());
}
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.get(idx).containsKey(p)) {
int value = Integer.MAX_VALUE;
for (int i = 0; i < 4; i++) {
value = Math.min(value, dfw(idx - 1, p - i) + points[idx][i]);
}
dp.get(idx).put(p, value);
}
return dp.get(idx).get(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();
}
}
tenten