結果

問題 No.5003 物理好きクリッカー
ユーザー Mizuwater0Mizuwater0
提出日時 2018-12-06 23:47:47
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 321 ms / 10,000 ms
コード長 12,243 bytes
コンパイル時間 833 ms
実行使用メモリ 21,948 KB
スコア 67,359,107,352
平均クエリ数 10000.00
最終ジャッジ日時 2021-07-19 09:00:35
合計ジャッジ時間 13,546 ms
ジャッジサーバーID
(参考情報)
judge10 / judge12
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<stdio.h>
#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];
    scanf("%d%s", &n, s);
    int comand[20000];
    //クッキーの量と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;
    //強化回数
    ll enhclitime = 0;
    ll rfgritime = 0;
    //grimoireの数(強化した場合は2倍になる)
    ll gritime = 0;
    //段階
    int level = 0;
    //目標金額
    ll amemoney;
    //目標金額上限
    ll amemax = 500000000000;
    //目標金額下限
    ll amemin = 0;
    int i = 0;
    while(i<n){
        //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;
                i++;
                cooky -= lily;
                lily = lily*6/5;
                clipro += 10;
                pro += 10;
                cooky += pro;
                level++;
            }
            //handを買う
            else 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;
                i++;
                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++;
                    //cout << cooky << endl;
                    cooky += clipro;
                }
                comand[i] = 11;
                i++;
                //cout << "ec " << i << endl;
                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;
                i++;
                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;
                i++;
                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;
                i++;
                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;
                i++;
                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;
                i++;
                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;
                i++;
                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;
            ll nowrfgritime = rfgritime;
            ll nowgrimoire = grimoire;
            ll nowgritime = gritime;
            ll nowpro = pro;
            ll nowclipro = clipro;
            //二部探索で達成可能クッキー数を調べていく
            while(1){
                if(amemax == amemin || amemax-1 == 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;
                        gritime *= 2;
                        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);
    }
    //cout << cooky << endl;
    return 0;
}
0