結果
問題 | No.2389 Cheating Code Golf |
ユーザー |
![]() |
提出日時 | 2023-07-21 22:02:10 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 13 ms / 2,000 ms |
コード長 | 1,151 bytes |
コンパイル時間 | 2,240 ms |
コンパイル使用メモリ | 200,768 KB |
最終ジャッジ日時 | 2025-02-15 16:54:22 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 50 |
ソースコード
#include <bits/stdc++.h>using namespace std;#ifdef tabr#include "library/debug.cpp"#else#define debug(...)#endifint main() {ios::sync_with_stdio(false);cin.tie(nullptr);int n, m;cin >> n >> m;vector<int> a(n), b(n), p(n);for (int i = 0; i < n; i++) {cin >> a[i] >> b[i] >> p[i];}vector<vector<double>> dp(m + 1, vector<double>(1 << n));for (int mask = (1 << n) - 1; mask >= 0; mask--) {for (int j = 0; j < n; j++) {if (mask & (1 << j)) {continue;}dp[m][mask] += 1.0 / a[j];}}for (int i = m - 1; i >= 0; i--) {dp[i] = dp[i + 1];for (int mask = (1 << n) - 1; mask >= 0; mask--) {for (int j = 0; j < n; j++) {if (mask & (1 << j)) {continue;}dp[i][mask] = max(dp[i][mask], (dp[i][mask ^ (1 << j)] + 1.0 / b[j]) / p[j] + (dp[i + 1][mask]) * (p[j] - 1) / p[j]);}}}cout << fixed << setprecision(12);cout << *max_element(dp[0].begin(), dp[0].end()) << '\n';return 0;}