結果

問題 No.472 平均順位
ユーザー pekempeypekempey
提出日時 2016-12-22 00:45:40
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 182 ms / 2,000 ms
コード長 786 bytes
コンパイル時間 1,717 ms
コンパイル使用メモリ 166,864 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-22 15:01:33
合計ジャッジ時間 3,639 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 5 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 6 ms
4,376 KB
testcase_08 AC 17 ms
4,376 KB
testcase_09 AC 37 ms
4,376 KB
testcase_10 AC 46 ms
4,380 KB
testcase_11 AC 70 ms
4,376 KB
testcase_12 AC 65 ms
4,380 KB
testcase_13 AC 181 ms
4,376 KB
testcase_14 AC 181 ms
4,376 KB
testcase_15 AC 182 ms
4,376 KB
testcase_16 AC 181 ms
4,376 KB
testcase_17 AC 181 ms
4,380 KB
testcase_18 AC 45 ms
4,380 KB
testcase_19 AC 172 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    int n, p;
    cin >> n >> p;

    vector<int> a(n), b(n), c(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i] >> c[i];
    }

    static int dp[2][15050];
    memset(dp[0], 0x3f, sizeof(dp[0]));
    dp[0][0] = 0;

    for (int i = 0; i < n; i++) {
        int *dp0 = dp[i & 1];
        int *dp1 = dp[~i & 1];
        memset(dp1, 0x3f, sizeof(dp[0]));
        for (int j = 0; j <= 15000; j++) {
            dp1[j + 0] = min(dp1[j + 0], dp0[j] + a[i]);
            dp1[j + 1] = min(dp1[j + 1], dp0[j] + b[i]);
            dp1[j + 2] = min(dp1[j + 2], dp0[j] + c[i]);
            dp1[j + 3] = min(dp1[j + 3], dp0[j] + 1);
        }
    }

    double ans = 1.0 * dp[n & 1][p] / n;
    printf("%.20f\n", ans);
}
0