結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 1 ms
4,356 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 1 ms
4,356 KB
testcase_04 AC 3 ms
9,816 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
5,716 KB
testcase_07 AC 3 ms
9,852 KB
testcase_08 AC 8 ms
28,488 KB
testcase_09 AC 21 ms
61,308 KB
testcase_10 AC 24 ms
75,596 KB
testcase_11 AC 47 ms
114,664 KB
testcase_12 AC 40 ms
106,516 KB
testcase_13 AC 219 ms
171,672 KB
testcase_14 MLE -
testcase_15 AC 215 ms
202,168 KB
testcase_16 MLE -
testcase_17 MLE -
testcase_18 AC 26 ms
73,880 KB
testcase_19 MLE -
権限があれば一括ダウンロードができます

ソースコード

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 dp[5005][15005];
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];
    }
    for (ll i = 0; i <= n; ++i) {
        for (ll j = 0; j <= p; ++j) {
            dp[i][j] = (1 << 30);
        }
    }
    dp[0][0] = 0;
    for (ll i = 0; i < n; ++i) {
        for (ll j = 0; j <= 3 * (i + 1); ++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