結果
| 問題 | No.5018 Let's Make a Best-seller Book |
| コンテスト | |
| ユーザー |
FplusFplusF
|
| 提出日時 | 2026-05-08 01:46:08 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 56 ms / 400 ms |
| コード長 | 7,848 bytes |
| 記録 | |
| コンパイル時間 | 2,245 ms |
| コンパイル使用メモリ | 339,424 KB |
| 実行使用メモリ | 30,320 KB |
| スコア | 106,181 |
| 平均クエリ数 | 52.00 |
| 最終ジャッジ日時 | 2026-05-08 01:46:22 |
| 合計ジャッジ時間 | 10,772 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge3_0 |
| 純コード判定しない問題か言語 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 100 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using tii=tuple<int,int,int>;
using qii=tuple<int,int,int,int>;
using ll=long long;
using ull=unsigned long long;
using ld=long double;
constexpr int INF=1e9;
constexpr ll INF_ll=1e18;
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define replr(i,l,r) for (int i=(int)(l);i<(int)(r);i++)
#define all(v) v.begin(),v.end()
#define len(v) ((int)v.size())
template<class T> inline bool chmin(T &a,T b){
if(a>b){
a=b;
return true;
}
return false;
}
template<class T> inline bool chmax(T &a,T b){
if(a<b){
a=b;
return true;
}
return false;
}
template<class T> inline bool chmin_ref(T &a,const T &b){
if(a>b){
a=b;
return true;
}
return false;
}
template<class T> inline bool chmax_ref(T &a,const T &b){
if(a<b){
a=b;
return true;
}
return false;
}
namespace Timer{
chrono::steady_clock::time_point program_start,start;
void program_start_snap(){
program_start=start=chrono::steady_clock::now();
}
void snap(){
start=chrono::steady_clock::now();
}
int get_ms(){
auto now=chrono::steady_clock::now();
int ms=chrono::duration_cast<chrono::milliseconds>(now-start).count();
return ms;
}
int get_ms_all_program(){
auto now=chrono::steady_clock::now();
int ms=chrono::duration_cast<chrono::milliseconds>(now-program_start).count();
return ms;
}
}
mt19937 mt(0);
uint32_t rand_int(uint32_t r){ //[0,r)
assert(r!=0);
return ((uint64_t)mt()*r)>>32;
}
int rand_int(int l,int r){ //[l,r)
assert(l<r);
return l+rand_int(r-l);
}
constexpr double one_div_mt_max=1.0/(double)mt19937::max();
double rand_double(){ //[0.0,1.0]
return mt()*one_div_mt_max;
}
double rand_double(double l,double r){ //[l,r]
return l+rand_double()*(r-l);
}
template<class T> T get_random_element(const vector<T> &v){
assert(!v.empty());
return v[rand_int(len(v))];
}
template<class T> void add(vector<T> &a,vector<T> b){
for(auto i:b) a.push_back(i);
}
template<class T> T binary_search(auto f,T ok,T ng){
while(1<abs(ok-ng)){
T mid=midpoint(ok,ng);
if(f(mid)) ok=mid;
else ng=mid;
}
return ok;
}
constexpr int T=52,N=10,M=2000000,B=500,C=500000;
namespace Communication{
int money=M;
#ifdef LOCAL
int turn=0;
int result=0;
array<double,N> D;
array<array<double,N>,T> Z;
array<int,N> P,R;
void init(){
turn=0;
result=0;
money=M;
P.fill(0);
R.fill(0);
rep(i,N){
D[i]=rand_double(0.5,1.5);
}
rep(t,T){
rep(i,N){
Z[t][i]=rand_double(0.75,1.25);
}
}
}
#endif
tuple<int,array<int,N>,array<int,N>,array<int,N>> query(int t,const array<int,N> &l,int x=-1){
if(t==1){
int sum=0;
rep(i,N) sum+=l[i];
assert(sum*B<=money);
#ifdef LOCAL
money-=sum*B;
rep(i,N){
R[i]+=l[i];
}
#else
cout << t << ' ';
rep(i,N) cout << l[i] << ' ';
cout << '\n';
cout.flush();
#endif
}else if(t==2){
assert(1<=x&&x<=5);
assert(C*(1<<(x-1))<=money);
#ifdef LOCAL
money-=C*(1<<(x-1));
rep(i,N){
P[i]+=x;
}
#else
cout << t << ' ' << x;
cout << '\n';
cout.flush();
#endif
}else{
assert(0);
}
#ifdef LOCAL
array<int,N> s;
rep(i,N){
s[i]=min<double>(R[i],sqrt(R[i])*pow(1.05,P[i])*D[i]*Z[turn][i]);
if(0<R[i]){
if(3*R[i]<=10*s[i]){
P[i]++;
}
if(10*s[i]<R[i]){
P[i]--;
}
P[i]=clamp(P[i],-60,60);
}
R[i]-=s[i];
money+=1000*s[i];
result+=s[i];
}
turn++;
return {money,s,P,R};
#else
cin >> money;
array<int,N> s,p,r;
rep(i,N) cin >> s[i];
rep(i,N) cin >> p[i];
rep(i,N) cin >> r[i];
return {money,s,p,r};
#endif
}
};
namespace Solver{
void solve(){
int money=M;
array<int,N> p,r;
p.fill(0);
r.fill(0);
array<int,N> sold;
sold.fill(0);
rep(turn,T){
array<int,N> l;
l.fill(0);
int t=1,x=-1;
if(T-5<=turn){
l.fill(money/B/N);
}else if(turn%3==2&&C*3<=money){
t=2;
x=2;
}else{
while(true){
bool fin=true;
rep(i,N){
auto f=[&](int now){
return pow(r[i]+now-1,0.83)<=pow(r[i]+now-1,0.5)*pow(1.05,p[i]);
};
if(f(l[i]+1)&&0<=money-B){
l[i]++;
money-=B;
fin=false;
}
}
if(fin) break;
}
}
auto [new_money,s,new_p,new_r]=Communication::query(t,l,x);
p=new_p;
r=new_r;
/*cerr << "turn:" << turn << " money:" << money << endl;
cerr << "s:";
rep(i,N){
cerr << s[i] << " ";
}
cerr << endl;
cerr << "p:";
rep(i,N){
cerr << p[i] << " ";
}
cerr << endl;
cerr << "r:";
rep(i,N){
cerr << r[i] << " ";
}
cerr << endl;
cerr << endl;*/
money=new_money;
rep(i,N) sold[i]+=s[i];
}
}
#ifdef LOCAL
void solve_many(){
int loop=1000;
int sum=0;
rep(_,loop){
Communication::init();
solve();
int score=(Communication::result+99)/100;
sum+=score;
}
cerr << sum << ' ' << Timer::get_ms() << '\n';
exit(0);
}
#endif
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
Timer::program_start_snap();
#ifdef LOCAL
Solver::solve_many();
#else
int t,n,m;
cin >> t >> n >> m;
assert(t==T);
assert(n==N);
assert(m==M);
#endif
Solver::solve();
exit(0);
}
FplusFplusF