結果
問題 | No.472 平均順位 |
ユーザー | tomorrow |
提出日時 | 2022-05-18 01:27:13 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 1,193 bytes |
コンパイル時間 | 2,949 ms |
コンパイル使用メモリ | 200,744 KB |
実行使用メモリ | 296,720 KB |
最終ジャッジ日時 | 2023-10-14 05:09:14 |
合計ジャッジ時間 | 8,216 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,352 KB |
testcase_01 | AC | 2 ms
4,352 KB |
testcase_02 | AC | 1 ms
4,348 KB |
testcase_03 | AC | 2 ms
4,352 KB |
testcase_04 | AC | 3 ms
9,820 KB |
testcase_05 | AC | 2 ms
4,356 KB |
testcase_06 | AC | 2 ms
5,676 KB |
testcase_07 | AC | 3 ms
9,756 KB |
testcase_08 | AC | 10 ms
28,436 KB |
testcase_09 | AC | 32 ms
61,420 KB |
testcase_10 | AC | 28 ms
75,452 KB |
testcase_11 | AC | 104 ms
114,860 KB |
testcase_12 | AC | 76 ms
106,600 KB |
testcase_13 | AC | 378 ms
171,492 KB |
testcase_14 | MLE | - |
testcase_15 | MLE | - |
testcase_16 | MLE | - |
testcase_17 | MLE | - |
testcase_18 | AC | 52 ms
73,940 KB |
testcase_19 | MLE | - |
ソースコード
#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); for (ll i = 0; i < n; ++i) { cin >> a[i] >> b[i] >> c[i]; } for (ll i = 0; i <= p; ++i) { for (ll j = 0; j <= n; ++j) { dp[j][i] = (1 << 30); } } 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; }