結果

問題 No.5018 Let's Make a Best-seller Book
ユーザー trineutrontrineutron
提出日時 2023-09-30 22:50:28
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 120 ms / 400 ms
コード長 3,964 bytes
コンパイル時間 2,230 ms
コンパイル使用メモリ 208,176 KB
実行使用メモリ 24,396 KB
スコア 152,122
平均クエリ数 52.00
最終ジャッジ日時 2023-10-01 12:33:38
合計ジャッジ時間 18,901 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 100
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <bits/stdc++.h>
using namespace std;
class xrand {
uint64_t x;
public:
using result_type = uint32_t;
static constexpr result_type min() {
return std::numeric_limits<result_type>::min();
}
static constexpr result_type max() {
return std::numeric_limits<result_type>::max();
}
xrand(uint64_t k) : x(k) {}
xrand() : xrand(1) {}
result_type operator()() {
x ^= x << 9;
x ^= x >> 7;
return (x * 0x123456789abcdef) >> 32;
}
};
xrand rng;
uniform_real_distribution<double> dist_d(0.5, 1.5);
constexpr int T = 52, N = 10;
constexpr int sample_size = 1000;
double calc_p(int s, int p, int r, double d) {
assert(s <= r);
const double base = sqrt(r) * pow(1.05, p) * d;
double low = clamp(s / base, 0.75, 1.25);
double high = clamp((s + 1) / base, 0.75, 1.25);
if (s == r) {
high = 1.25;
}
return (high - low) * 2;
}
int convert(int x) {
const int r = x % 10;
if (r == 0) return x;
if (r <= 3) return x + 3 - r;
if (r <= 6) return x + 6 - r;
return x + 10 - r;
}
int main() {
int t, n, money;
cin >> t >> n >> money;
money /= 500;
array<int, N> s, p, r;
s.fill(0);
p.fill(0);
r.fill(0);
array<array<double, sample_size>, N> d_particle;
for (int i = 0; i < N; i++) {
for (auto &&x : d_particle[i]) {
x = dist_d(rng);
}
}
int score = 0;
for (int week = 0; week < T; week++) {
array<double, N> d_avg;
for (int i = 0; i < N; i++) {
d_avg[i] = reduce(d_particle[i].begin(), d_particle[i].end()) /
sample_size;
}
if (week >= 44) {
double w_sum = 0.0;
array<double, N> weight;
for (int i = 0; i < N; i++) {
weight[i] = pow(1.05, 2 * p[i]) * d_avg[i] * d_avg[i];
w_sum += weight[i];
}
cout << 1;
for (int i = 0; i < 10; i++) {
cout << ' ' << int(money * weight[i] / w_sum);
}
cout << endl;
} else if (week % 3 != 1 or money < 2000) {
cout << 1;
for (int i = 0; i < 10; i++) {
cout << ' '
<< min(money / 10,
max(0, convert(1.5 * d_avg[i] * d_avg[i] *
pow(1.05, 3 * p.at(i))) -
r.at(i)));
}
cout << endl;
} else {
cout << "2 2" << endl;
}
cin >> money;
money /= 500;
for (int i = 0; i < N; i++) {
cin >> s[i];
score += s[i];
}
double p2_sum = 0;
for (int i = 0; i < N; i++) {
cin >> p[i];
for (int w = week + 1; w < T; w++) {
p2_sum +=
pow(1.05, 2 * min(60.0, p[i] + 1.1 * (w - week - 1))) *
d_avg[i] * d_avg[i];
}
}
for (auto &&x : r) {
cin >> x;
}
for (int i = 0; i < N; i++) {
array<double, sample_size> d_prob;
for (int j = 0; j < sample_size; j++) {
d_prob[j] = calc_p(s[i], p[i], r[i] + s[i], d_particle[i][j]);
}
discrete_distribution dist_idx(d_prob.begin(), d_prob.end());
array<double, sample_size> d_new;
for (int j = 0; j < sample_size; j++) {
d_new[j] = d_particle[i][dist_idx(rng)];
}
d_particle[i] = move(d_new);
}
// cerr << score + 5 * p2_sum << endl;
// if (week == T - 1) {
// for (int i = 0; i < N; i++) {
// cerr << reduce(d_particle[i].begin(), d_particle[i].end()) /
// sample_size
// << endl;
// }
// }
}
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0