結果

問題 No.5018 Let's Make a Best-seller Book
ユーザー PechiPechi
提出日時 2023-10-01 14:33:53
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 34 ms / 400 ms
コード長 4,362 bytes
コンパイル時間 3,234 ms
コンパイル使用メモリ 218,608 KB
実行使用メモリ 24,384 KB
スコア 32,652
平均クエリ数 52.08
最終ジャッジ日時 2023-10-01 14:34:05
合計ジャッジ時間 11,251 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 100
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
//#define NDEBUG
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#include<array>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<chrono>


using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
//#define SUBMIT
#ifdef SUBMIT
#define NO_DEBUG
#endif // SUBMIT
#define MAX(A,B) max(A,B)
#define MIN(A,B) min(A,B)
#define IN(X) 	for (int in = 0; in < X.size(); in++)cin >> X[in]
#define OUT(X) 	for (int in = 0; in < X.size(); in++)cout << X[in]<<(in==X.size()-1?"\n":" ")
#define SORT(X) sort(X.begin(), X.end())
#define ALL(X,Y) for (auto X = (Y).begin(); X != (Y).end(); ++X)
#define FULL(a)  (a).begin(),(a).end()
#define BFS(Q,S) for(Q.push(S);Q.size()!=0;Q.pop())

int dx[] = { 1,0,-1,0,0,0 };
int dy[] = { 0,1,0,-1,0,0 };
int dz[] = { 0,0,0,0,1,-1 };
int t, n, m;

chrono::system_clock::time_point starttime;
using namespace std::chrono;
#ifndef ONLINE_JUDGE
#define DEBUG
#endif

inline float getTime() {
#ifdef DEBUG
	return duration_cast<milliseconds>(system_clock::now() - starttime).count() * 2.0;
#else
	return duration_cast<milliseconds>(system_clock::now() - starttime).count();
#endif
}

inline long long int xor128() {
	static long long int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	long long int t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
int p[10] = { 0 }, r[10] = { 0 }, l[10] = { 0 };
double d[10], s[10],pl[10];


inline void solve() {
	cin >> t >> n >> m;
	for (int i = 0; i < n; ++i)d[i] = 1.0;
	for (int now = 0; now < t; ++now) {
		double sum = 0;
		int maxCnt = m / 500, cnt = 0;
		for (int i = 0; i < n; ++i) {
			pl[i] = (pow(d[i] / max(1, now), 2)*pow(5, 2 - 2 * p[i])*pow(21.0 / 4, 2 * p[i]) - 4 * r[i]) / 4.0;
			if (pl[i] < 0)pl[i] = 0;
			cnt += pl[i];
		}
		if (cnt == 0 && m >= 500000) {
			int x = 1;
			while (500000 * pow(2, x) <= m)++x;
			--x;
			if (x > 5)x = 5;
			cout << "2 " << x << endl;
			m -= 500000 * pow(2, x);
			for (int i = 0; i < n; ++i)p[i] += x;
		}
		else {
			cout << "1 ";
			for (int i = 0; i < n; ++i)l[i] = pl[i];
			while (cnt > maxCnt) {
				int id = xor128() % n;
				if (l[id] != 0)--l[id], --cnt;
			}
			for (int i = 0; i < n; ++i) {
				cout << l[i] << " ";
				r[i] += l[i];
				m -= l[i] * 500;
			}
		}
		cout << endl;
		int add;
		cin >> add;
		m += add;
		for (int i = 0; i < n; ++i) {
			cin >> s[i];
			s[i] /= sqrt(r[i])*pow(1.05, p[i]);
			if (now == 0)d[i] = 0;
			d[i] += s[i];
		}
		for (int i = 0; i < n; ++i)cin >> p[i];
		for (int i = 0; i < n; ++i)cin >> r[i];
	}
}

inline void test() {
	int score = 0;
	cin >> t >> n;
	m = 2000000;
	double D[10],z[10];
	for (int i = 0; i < n; ++i)d[i] = 1.0;
	for (int i = 0; i < n; ++i)cin >> D[i];
	for (int now = 0; now < t; ++now) {
		double sum = 0;
		int maxCnt = m / 500, cnt = 0;
		for (int i = 0; i < n; ++i) {
			pl[i] = (pow(d[i] / max(1, now), 2)*pow(5, 2 - 2 * p[i])*pow(21.0 / 4, 2 * p[i]) - 4 * r[i]) / 4.0;
			if (pl[i] < 0)pl[i] = 0;
			cnt += pl[i];
		}
		if (cnt == 0&&m>=500000) {
			int x = 1;
			while (500000 * pow(2, x) <= m)++x;
			--x;
			if (x > 5)x = 5;
			cout << "2 " << x << endl;
			m -= 500000 * pow(2, x);
			for (int i = 0; i < n; ++i)p[i] += x;
		}
		else {
			cout << "1 ";
			for (int i = 0; i < n; ++i)l[i] = pl[i];
			while (cnt > maxCnt) {
				int id = xor128() % n;
				if (l[id] != 0)--l[id], --cnt;
			}
			for (int i = 0; i < n; ++i) {
				cout << l[i] << " ";
				r[i] += l[i];
				m -= l[i] * 500;
			}
		}
		cout << endl;
		cout << m << "\n=>";
		for (int i = 0; i < n; ++i) {
			cin >> z[i];
			s[i] = min((double)r[i], sqrt(r[i])*pow(1.05, p[i])*D[i] * z[i]);
			m += (int)s[i] * 1000;
			score += (int)s[i];
			cout << (int)s[i] << " ";
			
		}
		cout <<"\n:"<< m << "\np:";
		for (int i = 0; i < n; ++i) {
			if (s[i] < 0.1*r[i])--p[i];
			if (s[i] >= 0.3*r[i])++p[i];
			if (p[i] < -60)p[i] = -60;
			if (p[i] > 60)p[i] = 60;
			cout << p[i]<<" ";
			s[i] /= sqrt(r[i])*pow(1.05, p[i]);
			if (now == 0)d[i] = 0;
			d[i] += s[i];
		}
		cout << "\n";
		for (int i = 0; i < n; ++i)r[i] -= s[i];
	}
	cout << score / 100;
}

int main(int argc, char* argv[]) {
	starttime = chrono::system_clock::now();
	ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	solve();

	exit(0);
}
0