結果
| 問題 |
No.2389 Cheating Code Golf
|
| コンテスト | |
| ユーザー |
Kude
|
| 提出日時 | 2023-07-21 22:46:01 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 29 ms / 2,000 ms |
| コード長 | 1,595 bytes |
| コンパイル時間 | 2,372 ms |
| コンパイル使用メモリ | 217,772 KB |
| 最終ジャッジ日時 | 2025-02-15 17:17:15 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 50 |
ソースコード
#include<bits/stdc++.h>
namespace {
#pragma GCC diagnostic ignored "-Wunused-function"
#include<atcoder/all>
#pragma GCC diagnostic warning "-Wunused-function"
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; }
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
int n, m;
struct S {
double a, b, p;
};
vector<S> d;
double e[1 << 12][41];
bool valid[1 << 12][41];
double dfs(int s, int w) {
if (s == (1 << n) - 1) return 0;
if (valid[s][w]) return e[s][w];
valid[s][w] = true;
if (w == m) {
double res = 0;
rep(i, n) if (!(s >> i & 1)) res += d[i].a;
return e[s][w] = res;
}
double mx = 0;
rep(i, n) if (!(s >> i & 1)) {
auto [a, b, p] = d[i];
chmax(mx, a + dfs(s | 1 << i, w));
chmax(mx, p * (b + dfs(s | 1 << i, w)) + (1 - p) * dfs(s, w + 1));
}
return e[s][w] = mx;
}
} int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> m;
d.resize(n);
for (auto& [a, b, p] : d) {
int ai, bi, pi;
cin >> ai >> bi >> pi;
a = 1.0 / ai;
b = 1.0 / bi;
p = 1.0 / pi;
}
double ans = dfs(0, 0);
cout << fixed << setprecision(15) << ans << endl;
}
Kude