結果
問題 | No.5003 物理好きクリッカー |
ユーザー | sinsincoscos |
提出日時 | 2018-12-04 18:16:00 |
言語 | C++11 (gcc 11.4.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 2,394 bytes |
コンパイル時間 | 403 ms |
実行使用メモリ | 21,984 KB |
スコア | 0 |
平均クエリ数 | 1.00 |
最終ジャッジ日時 | 2021-07-19 08:28:54 |
合計ジャッジ時間 | 21,159 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge10 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | RE | - |
testcase_01 | RE | - |
testcase_02 | RE | - |
testcase_03 | RE | - |
testcase_04 | RE | - |
testcase_05 | RE | - |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | RE | - |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | RE | - |
testcase_16 | RE | - |
testcase_17 | RE | - |
testcase_18 | RE | - |
testcase_19 | RE | - |
testcase_20 | RE | - |
testcase_21 | RE | - |
testcase_22 | RE | - |
testcase_23 | RE | - |
testcase_24 | RE | - |
testcase_25 | RE | - |
testcase_26 | RE | - |
testcase_27 | RE | - |
testcase_28 | RE | - |
testcase_29 | RE | - |
testcase_30 | RE | - |
testcase_31 | RE | - |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:57:33: warning: iteration 19 invokes undefined behavior [-Waggressive-loop-optimizations] for(int i=1;i<=20;i++) beki[i] = 2*beki[i-1]; ~~~~~~~~^~~~~~~~~~~~~ main.cpp:57:15: note: within this loop for(int i=1;i<=20;i++) beki[i] = 2*beki[i-1]; ~^~~~
ソースコード
#include <iostream> #include <stdio.h> #include <cassert> using namespace std; typedef long long ll; int N; int ans[10010][2] = {{0}}; ll resB[10010] = {0},resF[10010] = {0},resS[10010] = {0}; ll fac_num[6] = {0},fac_level[6] = {0},beki[20] = {1}; ll fac_price[6] = {0,150,2000,3000,60000,10000000};//逐次更新する ll fac_reinforce_price[6] = {15,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 print(){ 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; } bool is_purchase_good(int n,int time){ return beki[fac_level[n]]*(N-time+1+(resF[time]*7))+(beki[fac_level[n]]*resB[time]+99)/100 - fac_reinforce_price[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; for(int i=1;i<=N;i++){ int f = 0; ll ma = 0,gain = 0,loss = 0; for(int j=1;j<=5;j++){ if(fac_price[j]>money) continue; if(ma<is_purchase_good(j,i)){ f = j; ma = is_purchase_good(j,i); } } if(f==0 || fac_num[f]>=2){ gain++; ans[i][0] = 1; } else{ loss = fac_reinforce_price[f]; buy_fac(f); ans[i][0] = 2; ans[i][1] = f; } gain += gain_from_fac(); if(S[i-1]=='F') gain *= 7; if(S[i-1]=='S'){loss *= 9; loss = (loss+9)/10;} money += gain-loss; if(S[i-1]=='B') money += (money+99)/100; } /*for(int i=1;i<=N;i++){ cout << ans[i][0] << " " << ans[i][1] << endl; }*/ for(int i=1;i<=5;i++){ cerr << fac_num[i] << endl; } cerr << money << endl; print(); }