結果
| 問題 |
No.5003 物理好きクリッカー
|
| コンテスト | |
| ユーザー |
iicafiaxus
|
| 提出日時 | 2018-12-02 22:21:44 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
AC
|
| 実行時間 | 367 ms / 10,000 ms |
| コード長 | 2,230 bytes |
| コンパイル時間 | 1,620 ms |
| 実行使用メモリ | 21,996 KB |
| スコア | 17,456,280,027 |
| 平均クエリ数 | 10000.00 |
| 最終ジャッジ日時 | 2023-06-01 00:00:00 |
| 合計ジャッジ時間 | 15,613 ms |
|
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
| 純コード判定しない問題か言語 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 32 |
ソースコード
import std.stdio, std.conv, std.string, std.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
class Facility{
string name;
long benefit;
long cost;
long enhcost;
long level;
long amount = 0;
this(string na, long ben, long cost){
this.name = na;
this.benefit = ben;
this.cost = cost;
this.enhcost = cost * 10;
this.level = 1;
}
void buy(){
amount += 1;
cost = (cost * 6 + 4) / 5;
}
void enh(){
level += 1;
benefit *= 2;
enhcost *= 10;
}
}
void main(){
int n = read.to!int;
string s = readln.chomp;
Facility click = new Facility("click", 1, 15);
click.amount = 1;
Facility[] facs = [
new Facility("hand", 1, 150),
new Facility("lily", 10, 2_000),
new Facility("factory", 120, 30_000),
new Facility("casino", 2_000, 600_000),
new Facility("grimoire", 25_000, 10_000_000)
];
long value = 0;
foreach(i; n.iota){
string ans = "nothing";
real bestrate = 1.0;
Facility bestfac = click;
string bestmove = "";
foreach(fa; facs){
if(fa.cost > value) continue;
if(fa.benefit * (n - i) > fa.cost){
real rate = (fa.benefit * (n - i)).to!real / fa.cost.to!real;
if(rate > bestrate) bestrate = rate, bestfac = fa, bestmove = "buy";
}
}
foreach(fa; facs){
if(fa.enhcost > value) continue;
if(fa.benefit * fa.amount * (n - i) > fa.enhcost){
real rate = (fa.benefit * fa.amount * (n - i)).to!real / fa.enhcost.to!real;
if(rate > bestrate) bestrate = rate, bestfac = fa, bestmove = "reinforce";
}
}
if(bestfac.name == "click"){
ans = "click";
value += 1;
}
else if(bestmove == "buy"){
ans = "buy " ~ bestfac.name;
value -= bestfac.cost;
bestfac.buy;
debug ans ~= "(" ~ bestfac.amount.to!string ~ ")";
}
else if(bestmove == "reinforce"){
ans = "reinforce " ~ bestfac.name;
value -= bestfac.enhcost;
bestfac.enh;
debug ans ~= "(" ~ bestfac.level.to!string ~ ")";
}
foreach(fa; facs){
value += fa.benefit * fa.amount;
}
debug ans ~= " " ~ value.to!string;
ans.writeln;
stdout.flush;
readln;
}
}
iicafiaxus