結果
問題 | No.472 平均順位 |
ユーザー |
|
提出日時 | 2022-05-18 01:29:34 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 1,250 bytes |
コンパイル時間 | 7,111 ms |
コンパイル使用メモリ | 259,956 KB |
最終ジャッジ日時 | 2025-01-29 09:03:52 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 RE * 1 MLE * 1 |
other | AC * 11 RE * 1 TLE * 3 MLE * 1 |
ソースコード
#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));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);}}//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;}