結果

問題 No.5018 Let's Make a Best-seller Book
ユーザー wanuiwanui
提出日時 2023-10-01 18:29:52
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 34 ms / 400 ms
コード長 4,366 bytes
コンパイル時間 2,453 ms
コンパイル使用メモリ 212,080 KB
実行使用メモリ 24,492 KB
スコア 61,850
平均クエリ数 52.00
最終ジャッジ日時 2023-10-01 18:30:03
合計ジャッジ時間 10,478 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
23,520 KB
testcase_01 AC 27 ms
23,652 KB
testcase_02 AC 27 ms
23,664 KB
testcase_03 AC 27 ms
23,640 KB
testcase_04 AC 28 ms
23,376 KB
testcase_05 AC 28 ms
23,544 KB
testcase_06 AC 28 ms
24,396 KB
testcase_07 AC 27 ms
23,676 KB
testcase_08 AC 27 ms
23,664 KB
testcase_09 AC 27 ms
23,664 KB
testcase_10 AC 28 ms
24,348 KB
testcase_11 AC 27 ms
23,676 KB
testcase_12 AC 27 ms
23,640 KB
testcase_13 AC 27 ms
24,012 KB
testcase_14 AC 27 ms
24,324 KB
testcase_15 AC 27 ms
23,532 KB
testcase_16 AC 28 ms
24,276 KB
testcase_17 AC 27 ms
24,048 KB
testcase_18 AC 34 ms
24,336 KB
testcase_19 AC 28 ms
24,036 KB
testcase_20 AC 27 ms
24,036 KB
testcase_21 AC 28 ms
23,844 KB
testcase_22 AC 28 ms
23,676 KB
testcase_23 AC 27 ms
24,492 KB
testcase_24 AC 27 ms
23,532 KB
testcase_25 AC 27 ms
23,412 KB
testcase_26 AC 27 ms
23,640 KB
testcase_27 AC 27 ms
23,532 KB
testcase_28 AC 27 ms
23,364 KB
testcase_29 AC 27 ms
24,408 KB
testcase_30 AC 27 ms
23,412 KB
testcase_31 AC 28 ms
23,376 KB
testcase_32 AC 28 ms
24,048 KB
testcase_33 AC 28 ms
23,388 KB
testcase_34 AC 28 ms
24,396 KB
testcase_35 AC 27 ms
23,412 KB
testcase_36 AC 28 ms
24,348 KB
testcase_37 AC 28 ms
23,532 KB
testcase_38 AC 27 ms
24,060 KB
testcase_39 AC 28 ms
24,264 KB
testcase_40 AC 28 ms
24,048 KB
testcase_41 AC 27 ms
23,640 KB
testcase_42 AC 27 ms
24,276 KB
testcase_43 AC 27 ms
23,388 KB
testcase_44 AC 28 ms
23,640 KB
testcase_45 AC 27 ms
23,376 KB
testcase_46 AC 27 ms
24,336 KB
testcase_47 AC 27 ms
23,532 KB
testcase_48 AC 27 ms
24,360 KB
testcase_49 AC 28 ms
24,048 KB
testcase_50 AC 27 ms
24,024 KB
testcase_51 AC 28 ms
24,036 KB
testcase_52 AC 27 ms
24,024 KB
testcase_53 AC 28 ms
24,048 KB
testcase_54 AC 27 ms
23,652 KB
testcase_55 AC 27 ms
23,400 KB
testcase_56 AC 28 ms
23,844 KB
testcase_57 AC 27 ms
24,048 KB
testcase_58 AC 28 ms
24,408 KB
testcase_59 AC 27 ms
23,376 KB
testcase_60 AC 27 ms
24,264 KB
testcase_61 AC 28 ms
23,628 KB
testcase_62 AC 27 ms
24,396 KB
testcase_63 AC 28 ms
24,324 KB
testcase_64 AC 27 ms
24,036 KB
testcase_65 AC 27 ms
23,364 KB
testcase_66 AC 28 ms
24,048 KB
testcase_67 AC 27 ms
23,376 KB
testcase_68 AC 27 ms
23,652 KB
testcase_69 AC 28 ms
24,024 KB
testcase_70 AC 27 ms
24,036 KB
testcase_71 AC 28 ms
23,664 KB
testcase_72 AC 28 ms
23,412 KB
testcase_73 AC 28 ms
23,664 KB
testcase_74 AC 28 ms
24,396 KB
testcase_75 AC 28 ms
23,892 KB
testcase_76 AC 27 ms
23,640 KB
testcase_77 AC 28 ms
23,412 KB
testcase_78 AC 27 ms
23,640 KB
testcase_79 AC 27 ms
23,532 KB
testcase_80 AC 27 ms
23,364 KB
testcase_81 AC 28 ms
23,412 KB
testcase_82 AC 28 ms
24,264 KB
testcase_83 AC 27 ms
24,264 KB
testcase_84 AC 27 ms
23,604 KB
testcase_85 AC 27 ms
23,640 KB
testcase_86 AC 27 ms
23,664 KB
testcase_87 AC 27 ms
23,376 KB
testcase_88 AC 27 ms
23,664 KB
testcase_89 AC 28 ms
24,024 KB
testcase_90 AC 27 ms
23,832 KB
testcase_91 AC 27 ms
24,252 KB
testcase_92 AC 28 ms
23,412 KB
testcase_93 AC 27 ms
23,640 KB
testcase_94 AC 27 ms
23,400 KB
testcase_95 AC 27 ms
23,520 KB
testcase_96 AC 27 ms
24,036 KB
testcase_97 AC 28 ms
24,048 KB
testcase_98 AC 28 ms
24,036 KB
testcase_99 AC 27 ms
24,024 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
// clang-format off
using namespace std; using ll=long long; using ull=unsigned long long; using pll=pair<ll,ll>; const ll INF=4e18;
void print0(){}; template<typename H,typename... T> void print0(H h,T... t){cout<<h;print0(t...);}
void print(){print0("\n");}; template<typename H,typename... T>void print(H h,T... t){print0(h);if(sizeof...(T)>0)print0(" ");print(t...);}
void perr0(){}; template<typename H,typename... T> void perr0(H h,T... t){cerr<<h;perr0(t...);}
void perr(){perr0("\n");}; template<typename H,typename... T>void perr(H h,T... t){perr0(h);if(sizeof...(T)>0)perr0(" ");perr(t...);}
void ioinit() { cout<<fixed<<setprecision(15); cerr<<fixed<<setprecision(6); ios_base::sync_with_stdio(0); cin.tie(0); }
#define debug1(a) { cerr<<#a<<":"<<a<<endl; }
#define debug2(a,b) { cerr<<#a<<":"<<a<<" "<<#b<<":"<<b<<endl; }
#define debug3(a,b,c) { cerr<<#a<<":"<<a<<" "<<#b<<":"<<b<<" "<<#c<<":"<<c<<endl; }
#define debug4(a,b,c,d) { cerr<<#a<<":"<<a<<" "<<#b<<":"<<b<<" "<<#c<<":"<<c<<" "<<#d<<":"<<d<<endl; }
// clang-format on

const int T = 52;
const int N = 10;
struct state_t {
    vector<int> zaiko;
    vector<int> ninki;
    int money;
};
struct operation_t {
    int kind;
    int x;
    vector<int> send;
};
struct response_t {
    int money;
    vector<int> sell;
    vector<int> ninki;
    vector<int> zaiko;
};
operation_t selectop(int turn, state_t& state, vector<pair<operation_t, response_t>>& history) {
    if (turn == 1) {
        vector<int> send(N, 5);
        return operation_t{1, 0, send};
    }
    if(turn < 45 && turn % 2 == 0) {
      if (state.money >= 8000000 * 2) {
        return operation_t{2, 5, vector<int>()};
      }
      if (state.money >= 4000000 * 2) {
        return operation_t{2, 4, vector<int>()};
      }
      if (state.money >= 2000000 * 2) {
        return operation_t{2, 3, vector<int>()};
      }
      if (state.money >= 1000000 * 2) {
        return operation_t{2, 2, vector<int>()};
      }
      if (state.money >= 500000 * 2) {
        return operation_t{2, 1, vector<int>()};
      }
    }
    // 0.7Riだけ売る、最低3冊置いとく
    // 前週の売上を見る
    vector<int> send(N);
    for (int shop = 0; shop < N; shop++) {
        int lastsell = history[turn - 1].second.sell[shop];
        if (turn >= 2) lastsell = max(history[turn - 1].second.sell[shop], history[turn - 2].second.sell[shop]);

        // r=(state.zaiko[shop] + snd);
        // lastsell >= 0.5r
        int left = 0;
        int right = 9999999;
        int result = 0;
        while (left <= right) {
            int snd = (left + right) / 2;
            int r = (state.zaiko[shop] + snd);
            if (r * 0.5 <= lastsell) {
                result = snd;
                left = snd + 1;
            } else {
                right = snd - 1;
            }
        }
        result = max(3 - state.zaiko[shop], result);
        send[shop] = result;
    }
    int ttl=0;
    for(int s=0;s<N;s++){
    	ttl += 500*send[s];
    }
    if(ttl > state.money){
      double dec = 1.0* state.money / ttl;
      for(int s=0;s<N;s++){
      	send[s] = send[s]*dec - 2;
      	send[s] = max(send[s], 0);
      }
    }
    return operation_t{1, 0, send};
}
response_t output(operation_t& op) {
    if (op.kind == 1) {
        cout << "1";
        for (int l : op.send) {
            cout << " " << l;
        }
        cout << endl;
    } else {
        cout << "2 " << op.x << endl;
    }
    response_t res;
    cin >> res.money;
    res.sell.resize(N);
    res.ninki.resize(N);
    res.zaiko.resize(N);
    for (int shop = 0; shop < N; shop++) {
        cin >> res.sell[shop];
    }
    for (int shop = 0; shop < N; shop++) {
        cin >> res.ninki[shop];
    }
    for (int shop = 0; shop < N; shop++) {
        cin >> res.zaiko[shop];
    }
    return res;
}
void solve(state_t state) {
    vector<pair<operation_t, response_t>> history;
    for (int turn = 0; turn < T; turn++) {
        auto op = selectop(turn, state, history);
        auto resp = output(op);
        history.push_back({op, resp});

        state.money = resp.money;
        state.zaiko = resp.zaiko;
    }
}
int main() {
    ioinit();
    int _t, _n, _m;
    cin >> _t >> _n >> _m;
    state_t state;
    state.zaiko.resize(N, 0);
    state.ninki.resize(N, 0);
    state.money = _m;
    solve(state);
    return 0;
}
0