結果

問題 No.472 平均順位
ユーザー simansiman
提出日時 2022-09-15 00:18:03
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,088 bytes
コンパイル時間 4,617 ms
コンパイル使用メモリ 107,884 KB
実行使用メモリ 589,784 KB
最終ジャッジ日時 2023-08-21 21:44:15
合計ジャッジ時間 8,819 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 5 ms
6,492 KB
testcase_09 AC 20 ms
18,936 KB
testcase_10 AC 14 ms
12,892 KB
testcase_11 AC 59 ms
52,688 KB
testcase_12 AC 43 ms
37,972 KB
testcase_13 AC 164 ms
133,732 KB
testcase_14 MLE -
testcase_15 AC 167 ms
133,736 KB
testcase_16 MLE -
testcase_17 MLE -
testcase_18 AC 41 ms
37,172 KB
testcase_19 AC 83 ms
65,152 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <climits>
#include <map>
#include <queue>
#include <set>
#include <cstring>
#include <vector>

using namespace std;
typedef long long ll;

int main() {
  int N, P;
  cin >> N >> P;

  ll A[N];
  ll B[N];
  ll C[N];

  for (int i = 0; i < N; ++i) {
    cin >> A[i] >> B[i] >> C[i];
  }

  vector<vector<ll>> dp(N + 1, vector<ll>(P + 1, LLONG_MAX));
  dp[0][0] = 0;

  for (int i = 1; i <= N; ++i) {
    ll a = A[i - 1];
    ll b = B[i - 1];
    ll c = C[i - 1];

    for (int p = 0; p <= P; ++p) {
      if (dp[i - 1][p] != LLONG_MAX) {
        dp[i][p] = min(dp[i][p], dp[i - 1][p] + a);
        if (p + 1 <= P) {
          dp[i][p + 1] = min(dp[i][p + 1], dp[i - 1][p] + b);
        }
        if (p + 2 <= P) {
          dp[i][p + 2] = min(dp[i][p + 2], dp[i - 1][p] + c);
        }
        if (p + 3 <= P) {
          dp[i][p + 3] = min(dp[i][p + 3], dp[i - 1][p] + 1);
        }
      }
    }
  }

  cout << fixed << setprecision(10) << dp[N][P] * 1.0 / N << endl;

  return 0;
}
0