結果
| 問題 |
No.2099 [Cherry Alpha B] Time Machine
|
| コンテスト | |
| ユーザー |
ks2m
|
| 提出日時 | 2022-10-14 21:31:56 |
| 言語 | Java (openjdk 23) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 1,346 bytes |
| コンパイル時間 | 2,638 ms |
| コンパイル使用メモリ | 78,748 KB |
| 実行使用メモリ | 777,888 KB |
| 最終ジャッジ日時 | 2024-06-26 13:14:40 |
| 合計ジャッジ時間 | 9,855 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 5 MLE * 1 -- * 66 |
ソースコード
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
int x = sc.nextInt();
int a = sc.nextInt();
int y = sc.nextInt();
int b = sc.nextInt();
sc.close();
int m = 40000000;
int m2 = 20000000;
t += m2;
long[] d = new long[m];
Arrays.fill(d, Long.MAX_VALUE);
d[m2] = 0;
PriorityQueue<Node> que = new PriorityQueue<Node>();
Node first = new Node(m2, 0);
que.add(first);
int[] dx = {1, a, -b};
int[] dd = {1, x, y};
while (!que.isEmpty()) {
Node cur = que.poll();
if (cur.d > d[cur.v]) {
continue;
}
if (cur.v == t) {
System.out.println(d[cur.v]);
return;
}
for (int i = 0; i < 3; i++) {
int next = cur.v + dx[i];
if (next < 0 || m <= next) {
continue;
}
long alt = d[cur.v] + dd[i];
if (alt < d[next]) {
d[next] = alt;
que.add(new Node(next, alt));
}
}
}
}
static class Hen {
int v, c;
public Hen(int v, int c) {
this.v = v;
this.c = c;
}
}
static class Node implements Comparable<Node> {
int v;
long d;
public Node(int v, long d) {
this.v = v;
this.d = d;
}
public int compareTo(Node o) {
return Long.compare(d, o.d);
}
}
}
ks2m