結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 5 ms
5,332 KB
testcase_09 AC 16 ms
10,980 KB
testcase_10 AC 12 ms
8,580 KB
testcase_11 AC 47 ms
27,872 KB
testcase_12 AC 35 ms
20,584 KB
testcase_13 AC 136 ms
68,540 KB
testcase_14 AC 398 ms
243,832 KB
testcase_15 AC 135 ms
68,620 KB
testcase_16 MLE -
testcase_17 MLE -
testcase_18 AC 29 ms
20,220 KB
testcase_19 AC 69 ms
34,264 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;

  int A[N];
  int B[N];
  int C[N];

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

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

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

    for (int p = 0; p <= P; ++p) {
      if (dp[i - 1][p] != INT_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