結果

問題 No.5003 物理好きクリッカー
ユーザー Mizuwater0Mizuwater0
提出日時 2018-12-05 17:53:13
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 11,887 bytes
コンパイル時間 692 ms
実行使用メモリ 40,592 KB
スコア 0
最終ジャッジ日時 2021-07-19 08:47:59
合計ジャッジ時間 23,499 ms
ジャッジサーバーID
(参考情報)
judge11 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<string>
#include<functional>
using namespace std;
typedef	long long int ll;

ll min(ll a, ll b){
    if(a>b) return b;
    else return a;
}

int main(){
    int n;
    char s[10010];
    int comand[10000];
    scanf("%d%s", &n, s);
    //クッキーの量と1ターンあたりの生産量(クリック含まず、含む)
    ll cooky = 0;
    ll pro = 1;
    ll clipro = 1;
    //現在の施設価格
    ll click = 15;
    ll hand = 150;
    ll lily = 2000;
    ll factory = 30000;
    ll casino = 600000;
    ll grimoire = 10000000;
    //強化にかかるお金
    ll rfgri = 100000000;
    ll enhcli = 15;
    //強化回数
    int enhclitime = 0;
    int rfgritime = 0;
    //grimoireの数(強化した場合は2倍になる)
    int gritime = 0;
    //段階
    int level = 0;
    //目標金額
    ll amemoney;
    //目標金額上限
    ll amemax = 500000000000;
    //目標金額下限
    ll amemin = 0;
    for(int i = 0; i < n; i++){
        //lilyがない段階
        if(level==0){
            //lilyを買って段階上がる
            if((lily-cooky)/clipro <= min(lily/(clipro+1)+(hand-cooky)/clipro, (enhcli-cooky)/clipro+lily/(clipro+pow(2,enhclitime)))){
                while(cooky < lily){
                    comand[i] = 0;
                    i++;
                    cooky += clipro;
                }
                comand[i] = 2;
                cooky -= lily;
                lily = lily*6/5;
                clipro += 10;
                pro += 10;
                cooky += pro;
                level++;
                continue;
            }
            //handを買う
            if(lily/(clipro+1)+(hand-cooky)/clipro <= (enhcli-cooky)/clipro+lily/(clipro+pow(2,enhclitime))){
                while(cooky < hand){
                    comand[i] = 0;
                    i++;
                    cooky += clipro;
                }
                comand[i] = 1;
                cooky -= hand;
                if(hand%5 == 0){
                    hand = hand*6/5;
                }
                else{
                    hand = hand*6/5+1;
                }
                clipro += 1;
                pro += 1;
                cooky += pro;
                continue;
            }
            //clickを強化する
            if(lily/(clipro+1)+(hand-cooky)/clipro > (enhcli-cooky)/clipro+lily/(clipro+pow(2,enhclitime))){
                while(cooky < enhcli){
                    comand[i] = 0;
                    i++;
                    cooky += clipro;
                }
                comand[i] = 11;
                cooky -= enhcli;
                enhcli *= 10;
                clipro += pow(2,enhclitime);
                enhclitime++;
                cooky += pro;
                continue;
            }
        }
        //factoryがない段階
        if(level==1){
            //factoryを買って段階を上げる
            if((factory-cooky)/clipro <= factory/(clipro+10)+(lily-cooky)/clipro){
                 while(cooky < factory){
                    comand[i] = 0;
                    i++;
                    cooky += clipro;
                }
                comand[i] = 3;
                cooky -= factory;
                factory = factory*6/5;
                clipro += 120;
                pro += 120;
                cooky += pro;
                level++;
                continue;
            }
            //lilyを買う
            if((factory-cooky)/clipro > factory/(clipro+10)+(lily-cooky)/clipro){
                while(cooky < lily){
                    comand[i] = 0;
                    i++;
                    cooky += clipro;
                }
                comand[i] = 2;
                cooky -= lily;
                if(lily%5 == 0){
                    lily = lily*6/5;
                }
                else{
                    lily = lily*6/5+1;
                }
                clipro += 10;
                pro += 10;
                cooky += pro;
                continue;
            }
        }
        //casinoがない段階
        if(level==2){
            //casinoを買って段階を上げる
            if((casino-cooky)/clipro <= casino/(clipro+120)+(factory-cooky)/clipro){
                 while(cooky < casino){
                    comand[i] = 0;
                    i++;
                    cooky += clipro;
                }
                comand[i] = 4;
                cooky -= casino;
                casino = casino*6/5;
                clipro += 2000;
                pro += 2000;
                cooky += pro;
                level++;
                continue;
            }
            //factoryを買う
            if((casino-cooky)/clipro > casino/(clipro+120)+(factory-cooky)/clipro){
                while(cooky < factory){
                    comand[i] = 0;
                    i++;
                    cooky += clipro;
                }
                comand[i] = 3;
                cooky -= factory;
                if(factory%5 == 0){
                    factory = factory*6/5;
                }
                else{
                    factory = factory*6/5+1;
                }
                clipro += 120;
                pro += 120;
                cooky += pro;
                continue;
            }
        }
        //grimoireがない段階
        if(level==3){
            //grimoireを買って段階を上げる
            if((grimoire-cooky)/clipro <= grimoire/(clipro+2000)+(casino-cooky)/clipro){
                while(cooky < grimoire){
                    comand[i] = 0;
                    i++;
                    cooky += clipro;
                }
                comand[i] = 5;
                gritime++;
                cooky -= grimoire;
                grimoire = grimoire*6/5;
                clipro += 25000;
                pro += 25000;
                cooky += pro;
                level++;
                continue;
            }
            //factoryを買う
            if((grimoire-cooky)/clipro > grimoire/(clipro+2000)+(casino-cooky)/clipro){
                while(cooky < casino){
                    comand[i] = 0;
                    i++;
                    cooky += clipro;
                }
                comand[i] = 4;
                cooky -= casino;
                if(casino%5 == 0){
                    casino = casino*6/5;
                }
                else{
                    casino = casino*6/5+1;
                }
                clipro += 2000;
                pro += 2000;
                cooky += pro;
                continue;
            }
        }
        //全てそろった段階
        if(level==4){
            int j;
            //初期化用変数
            ll nowcooky = cooky;
            ll nowrfgri = rfgri;
            int nowrfgritime = rfgritime;
            ll nowgrimoire = grimoire;
            int nowgritime = gritime;
            ll nowpro = pro;
            ll nowclipro = clipro;
            //二部探索で達成可能クッキー数を調べていく
            while(1){
                if(amemax == amemin){
                    //ここにちゃんとcomandを目標ameminにするやつを入れるか?
                    break;
                }
                //初期化
                j = i;
                cooky = nowcooky;
                rfgri = nowrfgri;
                rfgritime = nowrfgritime;
                grimoire = nowgrimoire;
                gritime = nowgritime;
                pro = nowpro;
                clipro = nowclipro;
                //二部探索
                amemoney = (amemax+amemin)/2;
                while(1){
                    //目標クッキー数に挑戦
                    if((amemoney-cooky)/clipro <= min((rfgri-cooky)/clipro+amemoney/(clipro+gritime*25000), (grimoire-cooky)/clipro+amemoney/(clipro+25000))){
                        while(cooky < amemoney){
                            comand[j] = 0;
                            j++;
                            cooky += clipro;
                            if(j==n) break;
                        }
                        if(j==n && cooky < amemoney){
                            amemax = amemoney;
                            break;
                        }
                        amemin = amemoney;
                        break;
                    }
                    //grimoire追加購入
                    if(rfgri/gritime >= grimoire){
                        while(cooky < grimoire){
                            comand[j] = 0;
                            j++;
                            cooky += clipro;
                            if(j==n) break;
                        }
                        if(j==n-1 || j==n){
                            amemax = amemoney;
                            break;
                        }
                        comand[j] = 5;
                        j++;
                        gritime += pow(2,rfgritime);
                        cooky -= grimoire;
                        if(grimoire%5==0){
                            grimoire = grimoire*6/5;
                        }
                        else{
                            grimoire = grimoire*6/5+1;
                        }
                        clipro += 25000*pow(2,rfgritime);
                        pro += 25000*pow(2,rfgritime);
                        cooky += pro;
                        continue;
                    }
                    //grimoire強化
                    if(rfgri/gritime < grimoire){
                        while(cooky < rfgri){
                            comand[j] = 0;
                            j++;
                            cooky += clipro;
                            if(j==n) break;
                        }
                        if(j==n-1 || j==n){
                            amemax = amemoney;
                            break;
                        }
                        comand[j] = 16;
                        j++;
                        cooky -= rfgri;
                        rfgri *= 10;
                        rfgritime++;
                        clipro += gritime*25000;
                        pro += gritime*25000;
                        cooky += pro;
                        continue;
                    }
                }
            }
            break;
        }
    }
    for(int i = 0; i < n; i++){
        //コマンド列
        if(comand[i]==-1){
            printf("nothing\n");
        }
        if(comand[i]==0){
            printf("click\n");
        }
        if(comand[i]==1){
            printf("buy hand\n");
        }
        if(comand[i]==2){
            printf("buy lily\n");
        }
        if(comand[i]==3){
            printf("buy factory\n");
        }
        if(comand[i]==4){
            printf("buy casino\n");
        }
        if(comand[i]==5){
            printf("buy grimoire\n");
        }
        if(comand[i]==6){
            printf("sell hand\n");
        }
        if(comand[i]==7){
            printf("sell lily\n");
        }
        if(comand[i]==8){
            printf("sell factory\n");
        }
        if(comand[i]==9){
            printf("sell casino\n");
        }
        if(comand[i]==10){
            printf("sell grimoire\n");
        }
        if(comand[i]==11){
            printf("enhclick\n");
        }
        if(comand[i]==12){
            printf("reinforce hand\n");
        }
        if(comand[i]==13){
            printf("reinforce lily\n");
        }
        if(comand[i]==14){
            printf("reinforce factory\n");
        }
        if(comand[i]==15){
            printf("reinforce casino\n");
        }
        if(comand[i]==16){
            printf("reinforce grimoire\n");
        }
        fflush(stdout);
        scanf("%s", s);
    }
    return 0;
}
0