結果

問題 No.472 平均順位
ユーザー roiti46roiti46
提出日時 2016-10-11 23:30:27
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 194 ms / 2,000 ms
コード長 1,015 bytes
コンパイル時間 1,961 ms
コンパイル使用メモリ 144,040 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-22 14:51:14
合計ジャッジ時間 3,566 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 7 ms
4,380 KB
testcase_10 AC 5 ms
4,380 KB
testcase_11 AC 18 ms
4,376 KB
testcase_12 AC 13 ms
4,380 KB
testcase_13 AC 45 ms
4,380 KB
testcase_14 AC 159 ms
4,376 KB
testcase_15 AC 46 ms
4,380 KB
testcase_16 AC 183 ms
4,376 KB
testcase_17 AC 194 ms
4,380 KB
testcase_18 AC 13 ms
4,380 KB
testcase_19 AC 23 ms
4,380 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];

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

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

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

  return 0;
}
0