結果

問題 No.5003 物理好きクリッカー
ユーザー sinsincoscossinsincoscos
提出日時 2018-12-05 23:07:59
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 336 ms / 10,000 ms
コード長 5,399 bytes
コンパイル時間 474 ms
実行使用メモリ 21,996 KB
スコア 14,717,444,589
平均クエリ数 10000.00
最終ジャッジ日時 2021-07-19 08:49:06
合計ジャッジ時間 13,234 ms
ジャッジサーバーID
(参考情報)
judge11 / judge10
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 310 ms
21,684 KB
testcase_01 AC 314 ms
21,468 KB
testcase_02 AC 314 ms
21,828 KB
testcase_03 AC 336 ms
21,528 KB
testcase_04 AC 316 ms
21,816 KB
testcase_05 AC 310 ms
21,504 KB
testcase_06 AC 316 ms
21,540 KB
testcase_07 AC 319 ms
21,324 KB
testcase_08 AC 310 ms
21,732 KB
testcase_09 AC 312 ms
21,900 KB
testcase_10 AC 314 ms
21,888 KB
testcase_11 AC 311 ms
21,468 KB
testcase_12 AC 321 ms
21,852 KB
testcase_13 AC 312 ms
21,648 KB
testcase_14 AC 318 ms
21,516 KB
testcase_15 AC 311 ms
21,672 KB
testcase_16 AC 311 ms
21,504 KB
testcase_17 AC 318 ms
21,888 KB
testcase_18 AC 311 ms
21,324 KB
testcase_19 AC 311 ms
21,492 KB
testcase_20 AC 312 ms
21,828 KB
testcase_21 AC 313 ms
21,492 KB
testcase_22 AC 314 ms
21,624 KB
testcase_23 AC 312 ms
21,840 KB
testcase_24 AC 309 ms
21,684 KB
testcase_25 AC 312 ms
21,876 KB
testcase_26 AC 310 ms
21,468 KB
testcase_27 AC 312 ms
21,816 KB
testcase_28 AC 313 ms
21,516 KB
testcase_29 AC 310 ms
21,828 KB
testcase_30 AC 313 ms
21,540 KB
testcase_31 AC 311 ms
21,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <stdio.h>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
ll N;
int ans[10200][2] = {{0}};
ll resB[10200] = {0},resF[10200] = {0},resS[10200] = {0};
ll fac_num[6] = {0},fac_level[6] = {0},beki[21] = {1};
ll fac_price[6] = {15,150,2000,30000,600000,10000000};//逐次更新する
ll fac_reinforce_price[6] = {150,1500,20000,30000,600000,100000000};//逐次更新する
ll fac_gain[6] = {1,1,10,120,2000,25000};
string fac_name[6] = {"click","hand","lily","factory","casino","grimoire"};


string S,result;

void show(){
	for(int i=1;i<=N;i++){
		if(ans[i][0]==1) cout << "click" << endl;
		if(ans[i][0]==2) cout << "buy " << fac_name[ans[i][1]] << endl;
		if(ans[i][0]==3) cout << "sell " << fac_name[ans[i][1]] << endl;
		if(ans[i][0]==4) cout << "reinforce " << fac_name[ans[i][1]] << endl;
		if(ans[i][0]==5) cout << "enhclick" << endl;
		if(ans[i][0]==6) cout << "nothing" << endl;
		cin >> result;
//		assert(result=="ok");
	}
}


ll gain_from_fac(){
	ll gain = 0;
	for(int i=1;i<=5;i++) gain += beki[fac_level[i]]*fac_num[i]*fac_gain[i];
	return gain;
}


void reinforce_fac(int n){
	fac_level[n]++; fac_reinforce_price[n] *= 10;
}

void buy_fac(int n){
	fac_num[n]++; fac_price[n] = (fac_price[n]*6)/5;
}

ll sell_fac(int n){
	fac_num[n]--; ll t = (fac_price[n]+3)/4; fac_price[n] = (fac_price[n]*5)/6; return t;
}
ll is_purchase_good(int n,ll time){
	return fac_gain[n]*(beki[fac_level[n]]*(N-time+1+(resF[time]*7*20))+resB[time]*(beki[fac_level[n]]+99)/100) - fac_price[n];
}

ll is_reinforcement_good(int n,ll time){
	return fac_gain[n]*(beki[fac_level[n]+1]*fac_num[n]*(N-time+1+(resF[time]*7*20))+resB[time]*(beki[fac_level[n]+1]*fac_num[n]+99)/100) - fac_reinforce_price[n];	
}

ll cost_performance_buy(int n){
	return fac_price[n]/fac_gain[n];
}

ll cost_performance_reinforce(int n){
	return fac_reinforce_price[n]/(fac_gain[n]*2*fac_num[n]);
}

int main(){
	cin >> N >> S;
	fac_num[0] = 1;
	for(int i=1;i<=20;i++) beki[i] = 2*beki[i-1];
	for(int i=N;i>=1;i--){
		resB[i] = (S[i]=='B'); resB[i] += resB[i-1];
		resF[i] = (S[i]=='F'); resF[i] += resF[i-1];
		resS[i] = (S[i]=='S'); resS[i] += resS[i-1];
	}
	ll money = 0;
	int aim = 10;
	int cnt = 0,res = 0,fever = 0,cnt_click = 0;
	bool st = true;
	for(int i=1;i<=N;i++){
		ll gain = 0,loss = 0;
		int can = -1;
		for(int j=0;j<=5;j++){
			if(i>=10000-cnt) break;
			if(gain_from_fac()>fac_reinforce_price[j] && is_reinforcement_good(j,i)>0){
				can = j; ans[i][0] = 4; ans[i][1] = j; reinforce_fac(j);
				continue;
			}
		}
		if(can==-1){
			for(int j=1;j<=5;j++){
				if(i>=10000-cnt) break;
				if(gain_from_fac()>fac_price[j] && is_purchase_good(j,i)>0){
					can = j; ans[i][0] = 2; ans[i][1] = j; buy_fac(j);cnt++;
					continue;
				}
			}	
		}
		if(can==-1 && aim!=-1 && aim<10 && fac_price[aim]<=money && is_purchase_good(aim,i)>0){
			ans[i][0] = 2; ans[i][1] = aim;
			loss = fac_price[aim]; buy_fac(aim); cnt++;
			ll mi = 1e9;
			aim = -1;
			for(int j=1;j<=5;j++){
				if(mi > cost_performance_buy(j) && is_purchase_good(j,i+10)>0){
					mi = cost_performance_buy(j); aim = j;
				}
			}
			for(int j=0;j<=5;j++){
				if(fac_num[j]==0) continue;
				if(mi > cost_performance_reinforce(j) && is_reinforcement_good(j,i+10)>0){
					mi = cost_performance_reinforce(j); aim = j+10;
				}
			}
		}else if(can=-1 && aim>=10 && fac_reinforce_price[aim-10]<=money && is_reinforcement_good(aim-10,i)>0){
			aim -= 10;
			if(aim==0) ans[i][0] = 5;
			else{ans[i][0] = 4; ans[i][1] = aim;}
			loss = fac_reinforce_price[aim]; reinforce_fac(aim);
			ll mi = 1e9;
			aim = -1;
			for(int j=1;j<=5;j++){
				if(mi > cost_performance_buy(j) && is_purchase_good(j,i+10)>0){
					mi = cost_performance_buy(j); aim = j;
				}
			}
			for(int j=0;j<=5;j++){
				if(fac_num[j]==0) continue;
				if(mi > cost_performance_reinforce(j) && is_reinforcement_good(j,i+10)>0){
					mi = cost_performance_reinforce(j); aim = j+10;
				}
			}
		}else{
			if(i>=10000-cnt){
				if(st){
					for(int j=0;j<=5;j++){
						cerr << fac_num[j] << " " << fac_level[j] << endl;
						cerr << fac_price[j] << " " << fac_reinforce_price[j] << endl;
					}
					cerr << gain_from_fac() << endl;
					st = false;
				}
				if(fac_num[1]>0){gain += sell_fac(1); ans[i][0] = 3; ans[i][1] = 1;cnt--;}
				else if(fac_num[2]>0) {gain += sell_fac(2);ans[i][0] = 3; ans[i][1] = 2;cnt--;}
				else if(fac_num[3]>0) {gain += sell_fac(3);ans[i][0] = 3; ans[i][1] = 3;cnt--;}
				else if(fac_num[4]>0) {gain += sell_fac(4);ans[i][0] = 3; ans[i][1] = 4;cnt--;}
				else if(fac_num[5]>0) {gain += sell_fac(5);ans[i][0] = 3; ans[i][1] = 5;cnt--;}
				else {ans[i][0] = 1; gain += beki[fac_level[0]];}
			}else {ans[i][0] = 1; gain += beki[fac_level[0]]; cnt_click++;}
		}
		gain += gain_from_fac();
		if(S[i-1]=='F') fever = 20;
		if(fever>0){gain *= 7; fever--;}
		if(S[i-1]=='S'){loss *= 9; loss = (loss+9)/10;}
		money += gain-loss;
		if(S[i-1]=='B') money += (money+99)/100;
/*		if(i==5000){
			for(int j=0;j<=5;j++){
				cerr << fac_num[j] << " " << fac_level[j] << endl;
				cerr << fac_price[j] << " " << fac_reinforce_price[j] << endl;
			}
			cerr << gain_from_fac() << endl;
		}
*/	}
/*	for(int j=0;j<=5;j++){
		cerr << fac_num[j] << " " << fac_level[j] << endl;
		cerr << fac_price[j] << " " << fac_reinforce_price[j] << endl;
	}
*/	cerr << cnt_click << endl;
	cerr << money << endl;
	show();
}
0