結果
| 問題 |
No.1590 Random Shopping
|
| コンテスト | |
| ユーザー |
risujiroh
|
| 提出日時 | 2021-07-08 23:52:27 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 198 ms / 5,000 ms |
| コード長 | 1,065 bytes |
| コンパイル時間 | 2,566 ms |
| コンパイル使用メモリ | 208,012 KB |
| 最終ジャッジ日時 | 2025-01-22 19:40:39 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 |
ソースコード
#include <bits/stdc++.h>
int main() {
using namespace std;
cin.tie(nullptr)->sync_with_stdio(false);
int n;
cin >> n;
vector<int> a(n), r(n);
for (auto&& e : a) cin >> e;
for (auto&& e : r) cin >> e;
vector<int> order(n);
iota(begin(order), end(order), 0);
sort(begin(order), end(order), [&](int i, int j) { return a[i] < a[j]; });
vector<bool> marked(n);
vector p(n, vector<double>(n + 1));
for (int k = 1; k <= n; ++k) {
marked[order[k - 1]] = true;
vector<double> f{1};
for (int i = 0; i < n; ++i) {
if (marked[i]) f.insert(begin(f), 0);
p[i][k] = accumulate(begin(f) + 1, end(f), double(0));
vector<double> nf(size(f));
for (int x = 0; x < int(size(f)); ++x) {
nf[x] += f[x] / 2;
nf[max(x - 1, 0)] += f[x] / 2;
}
f = move(nf);
}
}
double ans = 0;
for (int i = 0; i < n; ++i)
for (int k = 1; k <= n; ++k) ans += (p[i][k] - p[i][k - 1]) * a[order[k - 1]] * r[i];
ans /= 2;
cout.precision(10);
cout << ans << '\n';
}
risujiroh