結果
| 問題 |
No.555 世界史のレポート
|
| ユーザー |
|
| 提出日時 | 2017-08-11 22:52:17 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 1,443 ms / 2,000 ms |
| コード長 | 1,626 bytes |
| コンパイル時間 | 3,986 ms |
| コンパイル使用メモリ | 79,392 KB |
| 実行使用メモリ | 99,300 KB |
| 最終ジャッジ日時 | 2024-10-12 21:35:17 |
| 合計ジャッジ時間 | 13,201 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 |
ソースコード
import java.io.*;
import java.util.*;
public class Main_yukicoder555 {
private static Scanner sc;
private static Printer pr;
private static void solve() {
int n = sc.nextInt();
int c = sc.nextInt();
int v = sc.nextInt();
int min = c + v * (n - 1);
PriorityQueue<Tuple> pq = new PriorityQueue<>();
pq.add(new Tuple(2, 1, c + v));
while (!pq.isEmpty()) {
Tuple e = pq.remove();
if (e.a >= n) {
min = Math.min(min, e.c);
continue;
}
if (e.c >= min) {
continue;
}
pq.add(new Tuple(2 * e.a, e.a, e.c + c + v));
pq.add(new Tuple(e.a + e.b, e.b, e.c + v));
}
pr.println(min);
}
private static class Tuple implements Comparable<Tuple> {
int a; // length
int b; // clip
int c; // cost
Tuple(int a, int b, int c) {
this.a = a;
this.b = b;
this.c = c;
}
@Override
public int compareTo(Tuple o) {
if (c == o.c) {
return Integer.compare(a, o.a);
}
return Integer.compare(c, o.c);
}
@Override
public int hashCode() {
return Integer.hashCode(a);
}
@Override
public String toString() {
// [xxx, xxxx]
StringBuilder stmp = new StringBuilder(32);
stmp.append('[');
stmp.append(a);
stmp.append(',');
stmp.append(' ');
stmp.append(b);
stmp.append(']');
return stmp.toString();
}
}
// ---------------------------------------------------
public static void main(String[] args) {
sc = new Scanner(System.in);
pr = new Printer(System.out);
solve();
pr.close();
sc.close();
}
private static class Printer extends PrintWriter {
Printer(PrintStream out) {
super(out);
}
}
}