結果

問題 No.5018 Let's Make a Best-seller Book
ユーザー 👑 binapbinap
提出日時 2023-10-01 15:56:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 36 ms / 400 ms
コード長 3,825 bytes
コンパイル時間 4,318 ms
コンパイル使用メモリ 245,640 KB
実行使用メモリ 24,420 KB
スコア 35,207
平均クエリ数 52.00
最終ジャッジ日時 2023-10-01 15:56:42
合計ジャッジ時間 12,824 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long>> vvl;
typedef long double ld;

const bool debug = false;

int T, N;
long long Money;
vector<long long> L;
vector<long long> S, P, R;
vector<long double> D;
vector<vector<long double>> D_est;
vector<vector<long double>> Z;
set<int> grow, waste;
int X = 1;
long long Score = 0;

vector<int> bi = {1, 2, 4, 8, 16};

void out(int type){
	if(!debug){
		if(type == 1){
			cout << 1;
			rep(i, N) cout << " " << L[i];
			cout << "\n";
		}
		if(type == 2){
			cout << 2 << " " << X << "\n";
		}
	}else{
		if(type == 2){
			rep(i, N) P[i] += X;
		}
	}
}

void in(int t){
	vector<long long> P_before = P;
	if(debug){
		rep(i, N) R[i] += L[i];
		rep(i, N){
			if(R[i] == 0){
				S[i] = 0;
			}else{
				S[i] = min(R[i], (long long)(sqrtl(R[i]) * pow(1.05, P[i]) * D[i] * Z[t][i]));
				if(S[i] * 10 >= R[i] * 3) P[i]++;
				if(S[i] * 10 < R[i]) P[i]--;
				R[i] -= S[i];
				Money += 1000 * S[i];
			}
			Score += S[i];
		}
		cout << Money << "\n";
		rep(i, N) cout << S[i] << " "; cout << "\n";
		rep(i, N) cout << P[i] << " "; cout << "\n";
		rep(i, N) cout << R[i] << " "; cout << "\n";
	}else{
		cin >> Money;
		rep(i, N) cin >> S[i];
		rep(i, N) cin >> P[i];
		rep(i, N) cin >> R[i];
	}
	rep(i, N) if(R[i] + S[i] > 0){
		if(R[i] + S[i] == 0){
			long double tmp = S[i] / sqrtl(R[i] + S[i]) / pow(1.05, P_before[i]);
			if(tmp < 0.5) tmp = 0.5;
			if(tmp >= 1.5) tmp = 1.5;
			D_est[i].push_back((tmp + 1.5) / 2);
		}else{
			long double tmp = (S[i] + 0.5) / sqrtl(R[i] + S[i]) / pow(1.05, P_before[i]);
			if(tmp < 0.5) tmp = 0.5;
			if(tmp >= 1.5) tmp = 1.5;
			D_est[i].push_back(tmp);
		}
	}
}

long double get_ave(int i){
	long double ave = 0;
	for(ld x : D_est[i]) ave += x;
	ave /= D_est[i].size();
	return ave;
//	if(debug) cout << ave << ' ';
}

long long solve(int i){
	long long ok = 1, ng = 1001001001001;
	while(ng - ok > 1){
		long long mid = (ok + ng) / 2;
		if(sqrtl(mid) * pow(1.05, P[i]) * get_ave(i) * 0.6 >= 0.3 * mid) ok = mid;
		else ng = mid;
	}
	return ok;
}

int main() {
	// 最初の入力
	if(debug){
		cin >> T >> N;
		Money = 2000000;
	}else cin >> T >> N >> Money;
	L.resize(N);
	S.resize(N);
	P.resize(N);
	R.resize(N);
	D.resize(N);
	Z.resize(T, vector<long double>(N));
	rep(i, N) grow.insert(i);
	if(debug){
		rep(i, N) cin >> D[i];
		rep(t, T) rep(i, N) cin >> Z[t][i];
	}
	D_est.resize(N);

	int start = 20;
	int end = 40;

	// インタラクティブ開始
	rep(t, T){
		rep(i, N) L[i] = 0;
		if(t < 3){
			X = 1;
			Money -= 500000 * bi[X - 1];
			out(2);
		}else if(t < start){
			{
				set<int> tmp;
				for(int i : grow){
					if(P[i] <= 0) tmp.insert(i);
				}
				for(int i : tmp){
					grow.erase(i);
					waste.insert(i);
				}
			}
			for(int i : grow){
				L[i] = min(3 - R[i], Money / 500);
				Money -= 500 * L[i];
			}
			for(int i : waste){
				L[i] = (Money / 5) / (500 * waste.size());
				Money -= 500 * L[i];
			}
			out(1);
		}else if(t < end){
			{
				set<int> tmp;
				for(int i : grow){
					if(P[i] <= 9) tmp.insert(i);
				}
				for(int i : tmp){
					grow.erase(i);
					waste.insert(i);
				}
			}
			for(int i : grow){
				L[i] = min(solve(i), Money / 500);
				Money -= 500 * L[i];
			}
			out(1);
		}else{
			for(int i : grow){
				L[i] = Money / (500 * int(grow.size()));
				Money -= 500 * L[i];
			}
			out(1);
		}
		in(t);
	}
	if(debug) cout << Score;
	return 0;
}



// CHECK DEBUG FLAG!!!!
// CHECK DEBUG FLAG!!!!
// CHECK DEBUG FLAG!!!!

// CHECK DEBUG FLAG!!!!
// CHECK DEBUG FLAG!!!!
// CHECK DEBUG FLAG!!!!

// CHECK DEBUG FLAG!!!!
// CHECK DEBUG FLAG!!!!
// CHECK DEBUG FLAG!!!!
0