結果

問題 No.5003 物理好きクリッカー
ユーザー iicafiaxusiicafiaxus
提出日時 2018-12-01 01:09:09
言語 D
(dmd 2.107.1)
結果
AC  
実行時間 334 ms / 10,000 ms
コード長 1,459 bytes
コンパイル時間 2,004 ms
実行使用メモリ 21,996 KB
スコア 8,710,933,110
平均クエリ数 10000.00
最終ジャッジ日時 2023-06-01 00:00:00
合計ジャッジ時間 15,095 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
純コード判定しない問題か言語
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 321 ms
21,516 KB
testcase_01 AC 312 ms
21,348 KB
testcase_02 AC 313 ms
21,528 KB
testcase_03 AC 311 ms
21,876 KB
testcase_04 AC 319 ms
21,516 KB
testcase_05 AC 309 ms
21,936 KB
testcase_06 AC 303 ms
21,864 KB
testcase_07 AC 302 ms
21,672 KB
testcase_08 AC 334 ms
21,336 KB
testcase_09 AC 317 ms
21,516 KB
testcase_10 AC 303 ms
21,372 KB
testcase_11 AC 302 ms
21,828 KB
testcase_12 AC 309 ms
21,348 KB
testcase_13 AC 306 ms
21,852 KB
testcase_14 AC 304 ms
21,516 KB
testcase_15 AC 303 ms
21,900 KB
testcase_16 AC 301 ms
21,192 KB
testcase_17 AC 296 ms
21,504 KB
testcase_18 AC 305 ms
21,624 KB
testcase_19 AC 304 ms
21,348 KB
testcase_20 AC 328 ms
21,900 KB
testcase_21 AC 333 ms
21,384 KB
testcase_22 AC 308 ms
21,900 KB
testcase_23 AC 323 ms
21,372 KB
testcase_24 AC 322 ms
21,540 KB
testcase_25 AC 303 ms
21,924 KB
testcase_26 AC 312 ms
21,516 KB
testcase_27 AC 306 ms
21,504 KB
testcase_28 AC 307 ms
21,852 KB
testcase_29 AC 306 ms
21,972 KB
testcase_30 AC 305 ms
21,720 KB
testcase_31 AC 310 ms
21,912 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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 amount = 0;
	this(string na, long ben, long cost){
		this.name = na;
		this.benefit = ben;
		this.cost = cost;
	}
	void buy(){
		amount += 1;
		cost = (cost * 6 + 4) / 5;
	}
}

void main(){
	int n = read.to!int;
	string s = readln.chomp;
	
	Facility click =	new Facility("click", 1, 15);
	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;
		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;
			}
		}
		if(bestfac.name == "click"){
			ans = "click";
			value += 1;
		}
		else{
			ans = "buy " ~ bestfac.name;
			value -= bestfac.cost;
			bestfac.buy;
		}
		foreach(fa; facs){
			value += fa.benefit * fa.amount;
		}
		
		ans.writeln;
		stdout.flush;
		readln;
	}
}
0