結果

問題 No.472 平均順位
ユーザー tactac
提出日時 2019-05-05 19:52:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,568 bytes
コンパイル時間 877 ms
コンパイル使用メモリ 102,716 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-08 03:31:26
合計ジャッジ時間 3,969 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 3 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 6 ms
4,376 KB
testcase_09 AC 17 ms
4,380 KB
testcase_10 AC 13 ms
4,380 KB
testcase_11 AC 50 ms
4,380 KB
testcase_12 AC 37 ms
4,380 KB
testcase_13 AC 144 ms
4,380 KB
testcase_14 AC 405 ms
4,380 KB
testcase_15 AC 144 ms
4,380 KB
testcase_16 AC 439 ms
4,380 KB
testcase_17 AC 453 ms
4,380 KB
testcase_18 WA -
testcase_19 AC 74 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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(4) << 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;}
}
0