結果

問題 No.472 平均順位
ユーザー ks115ks115
提出日時 2020-05-09 22:43:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 254 ms / 2,000 ms
コード長 926 bytes
コンパイル時間 1,449 ms
コンパイル使用メモリ 168,196 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-20 09:37:18
合計ジャッジ時間 3,375 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 9 ms
4,380 KB
testcase_10 AC 7 ms
4,380 KB
testcase_11 AC 24 ms
4,380 KB
testcase_12 AC 18 ms
4,376 KB
testcase_13 AC 61 ms
4,380 KB
testcase_14 AC 208 ms
4,376 KB
testcase_15 AC 60 ms
4,380 KB
testcase_16 AC 239 ms
4,376 KB
testcase_17 AC 254 ms
4,380 KB
testcase_18 AC 17 ms
4,376 KB
testcase_19 AC 32 ms
4,376 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<int> dp(P + 1, 1 << 30);
    dp[0] = 0;
    REP(i, 0, N) {
        for (int j = P; j >= 0; j--) {
            if (j + 1 <= P) dp[j + 1] = min(dp[j + 1], dp[j] + B[i]);
            if (j + 2 <= P) dp[j + 2] = min(dp[j + 2], dp[j] + C[i]);
            if (j + 3 <= P) dp[j + 3] = min(dp[j + 3], dp[j] + 1);
            dp[j] = dp[j] + A[i];
        }

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

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