結果

問題 No.472 平均順位
ユーザー ks115ks115
提出日時 2020-05-09 22:26:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,025 bytes
コンパイル時間 1,974 ms
コンパイル使用メモリ 169,480 KB
実行使用メモリ 296,312 KB
最終ジャッジ日時 2023-09-20 09:32:36
合計ジャッジ時間 4,746 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 5 ms
5,336 KB
testcase_09 AC 18 ms
11,088 KB
testcase_10 AC 12 ms
8,616 KB
testcase_11 AC 51 ms
27,824 KB
testcase_12 AC 37 ms
20,524 KB
testcase_13 AC 130 ms
68,624 KB
testcase_14 AC 463 ms
243,756 KB
testcase_15 AC 130 ms
68,604 KB
testcase_16 MLE -
testcase_17 MLE -
testcase_18 AC 35 ms
20,496 KB
testcase_19 AC 64 ms
34,164 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N, P; cin >> N >> P;
    vector<int> A(N), B(N), C(N);
    REP(i, 0, N) cin >> A[i] >> B[i] >> C[i];

    vector<vector<int>> dp(N + 1, vector<int>(P + 1, 1 << 30));
    dp[0][0] = 0;
    REP(i, 0, N) {
        REP(j, 0, P + 1) {
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + A[i]);
            if (j + 1 <= P) dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + B[i]);
            if (j + 2 <= P) dp[i + 1][j + 2] = min(dp[i + 1][j + 2], dp[i][j] + C[i]);
            if (j + 3 <= P) dp[i + 1][j + 3] = min(dp[i + 1][j + 3], dp[i][j] + 1);
        }
    }

    // REP(i, 0, N + 1) {
    //     REP(j, 0, P + 1) {
    //         cout << setw(12) << setfill(' ') << dp[i][j];
    //     }
    //     cout << endl;
    // }

    cout << fixed << setprecision(15);
    cout << (double)dp[N][P] / N << endl;
    return 0;
}
0