結果

問題 No.472 平均順位
ユーザー simansiman
提出日時 2022-09-15 00:14:15
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,037 bytes
コンパイル時間 1,225 ms
コンパイル使用メモリ 107,720 KB
実行使用メモリ 296,416 KB
最終ジャッジ日時 2023-08-21 21:41:29
合計ジャッジ時間 7,368 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 3 ms
4,384 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 WA -
testcase_05 AC 1 ms
4,380 KB
testcase_06 WA -
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 4 ms
5,296 KB
testcase_09 AC 14 ms
11,052 KB
testcase_10 WA -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 AC 316 ms
244,420 KB
testcase_15 RE -
testcase_16 MLE -
testcase_17 MLE -
testcase_18 AC 23 ms
20,280 KB
testcase_19 RE -
権限があれば一括ダウンロードができます

ソースコード

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 <= (i - 1) * 3; ++p) {
      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