結果
| 問題 |
No.472 平均順位
|
| コンテスト | |
| ユーザー |
tac
|
| 提出日時 | 2019-05-05 19:56:04 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 446 ms / 2,000 ms |
| コード長 | 1,568 bytes |
| コンパイル時間 | 1,541 ms |
| コンパイル使用メモリ | 102,336 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-25 20:45:21 |
| 合計ジャッジ時間 | 3,380 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 16 |
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
#include<climits>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
int main() {
int n, p; cin >> n >> p;
//使い回す
double dp[2][3 * 15001]; rep(i, 2) rep(j, 3 * 15001) dp[i][j] = inf;
rrep(i, 1, n + 1) {
int a[4]; rep(j, 3) cin >> a[j]; a[3] = 1;
if (i == 1) {rep(j, 4) dp[1][j] = a[j]; continue;}
int knew = (i % 2 == 0 ? 0 : 1);
int kold = (knew == 0 ? 1 : 0);
rep(k, 4) {
for (int j = p; j >= 0; --j) {
if (dp[kold][j] != inf) {
if (k == 0) dp[knew][j + k] = (dp[kold][j] * (i - 1) + a[k]) / i;
else chmin(dp[knew][j + k], (dp[kold][j] * (i - 1) + a[k]) / i);
}
}
}
if (i == n) cout << fixed << setprecision(5) << dp[knew][p] << endl;
//cout << endl; rep(j, 2) {rep(k, p + 1) cout << setw(7) << left << dp[j][k] << " "; cout << endl;}
}
//rep(i, 2) {rep(j, p + 1) cout << dp[i][j] << " "; cout << endl;}
}
tac