結果

問題 No.472 平均順位
ユーザー roiti46roiti46
提出日時 2016-12-21 20:52:28
言語 C++11
(gcc 11.4.0)
結果
MLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,087 bytes
コンパイル時間 2,597 ms
コンパイル使用メモリ 143,916 KB
実行使用メモリ 295,024 KB
最終ジャッジ日時 2023-08-21 05:12:08
合計ジャッジ時間 4,322 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
5,944 KB
testcase_08 AC 7 ms
22,356 KB
testcase_09 AC 18 ms
42,824 KB
testcase_10 AC 10 ms
22,336 KB
testcase_11 AC 39 ms
67,460 KB
testcase_12 AC 28 ms
51,228 KB
testcase_13 AC 82 ms
67,616 KB
testcase_14 AC 572 ms
191,268 KB
testcase_15 AC 79 ms
67,620 KB
testcase_16 MLE -
testcase_17 MLE -
testcase_18 AC 33 ms
73,544 KB
testcase_19 AC 39 ms
34,748 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<typename T> using Graph = vector<vector<T>>;

#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (__typeof(a.begin()) x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define endl '\n'

const int inf = 1e9;
int N, P;
int dp[15005][5005];

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> N >> P;
  rep(i, P + 1) dp[i][0] = inf;
  rep(i, N) {
    int a, b, c;
    cin >> a >> b >> c;
    if (i == 0) {
      dp[0][0] = a; dp[1][0]  = b; dp[2][0]  = c; dp[3][0]  = 1;
    }
    else {
      for (int j = P; j > -1; j--) {
        dp[j][0]  = dp[j][0]  + a;
        if (j > 0) dp[j][0]  = min(dp[j][0] , dp[j - 1][0]  + b);
        if (j > 1) dp[j][0]  = min(dp[j][0] , dp[j - 2][0]  + c);
        if (j > 2) dp[j][0]  = min(dp[j][0] , dp[j - 3][0]  + 1);
      }
    }
  }

  printf("%.10f", 1.0*dp[P][0] /N);

  return 0;
}
0