結果

問題 No.472 平均順位
ユーザー tomorrowtomorrow
提出日時 2022-05-18 01:33:05
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,143 bytes
コンパイル時間 2,079 ms
コンパイル使用メモリ 204,704 KB
実行使用メモリ 296,392 KB
最終ジャッジ日時 2023-10-14 05:12:44
合計ジャッジ時間 4,884 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 1 ms
4,352 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 5 ms
5,320 KB
testcase_09 AC 16 ms
10,904 KB
testcase_10 AC 11 ms
8,368 KB
testcase_11 AC 45 ms
27,808 KB
testcase_12 AC 33 ms
20,572 KB
testcase_13 AC 116 ms
68,620 KB
testcase_14 AC 396 ms
243,744 KB
testcase_15 AC 116 ms
68,572 KB
testcase_16 MLE -
testcase_17 MLE -
testcase_18 AC 30 ms
20,148 KB
testcase_19 AC 58 ms
34,304 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <typename T>
bool chmax(T& a, const T& b)
{
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <typename T>
bool chmin(T& a, const T& b)
{
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
constexpr ll inf = (1LL << 62);
int main()
{
    ll n, p;
    cin >> n >> p;
    vector<int> a(n), b(n), c(n);
    vector<vector<int>> dp(n + 1, vector<int>(p + 1, (1 << 30)));
    for (ll i = 0; i < n; ++i) {
        cin >> a[i] >> b[i] >> c[i];
    }
    //int dp[5005][15005];
    dp[0][0] = 0;
    for (ll i = 0; i < n; ++i) {
        for (ll j = 0; j <= p; ++j) {
            if (j >= 3) {
                chmin(dp[i + 1][j], dp[i][j - 3] + 1);
            }
            if (j >= 2) {
                chmin(dp[i + 1][j], dp[i][j - 2] + c[i]);
            }
            if (j >= 1) {
                chmin(dp[i + 1][j], dp[i][j - 1] + b[i]);
            }
            chmin(dp[i + 1][j], dp[i][j] + a[i]);
        }
    }
    cout << fixed << setprecision(10) << static_cast<double>(dp[n][p]) / n << endl;
}
0