結果

問題 No.472 平均順位
ユーザー koba-e964koba-e964
提出日時 2016-12-23 01:37:55
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 159 ms / 2,000 ms
コード長 626 bytes
コンパイル時間 733 ms
コンパイル使用メモリ 58,236 KB
実行使用メモリ 4,888 KB
最終ジャッジ日時 2023-08-22 15:06:42
合計ジャッジ時間 2,373 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,664 KB
testcase_01 AC 2 ms
4,844 KB
testcase_02 AC 2 ms
4,656 KB
testcase_03 AC 2 ms
4,868 KB
testcase_04 AC 2 ms
4,712 KB
testcase_05 AC 3 ms
4,644 KB
testcase_06 AC 3 ms
4,876 KB
testcase_07 AC 2 ms
4,656 KB
testcase_08 AC 4 ms
4,768 KB
testcase_09 AC 9 ms
4,660 KB
testcase_10 AC 12 ms
4,852 KB
testcase_11 AC 26 ms
4,644 KB
testcase_12 AC 23 ms
4,824 KB
testcase_13 AC 159 ms
4,648 KB
testcase_14 AC 158 ms
4,656 KB
testcase_15 AC 159 ms
4,888 KB
testcase_16 AC 158 ms
4,780 KB
testcase_17 AC 159 ms
4,828 KB
testcase_18 AC 12 ms
4,880 KB
testcase_19 AC 143 ms
4,656 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <iostream>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;

const int W = 150100;

int dp[2][W];
const int inf = 1e9;

int main(void){
  int n, p;
  cin >> n >> p;
  REP(j, 0, W) {
    dp[0][j] = dp[1][j] = inf;
  }
  dp[0][0] = 0;
  REP(i, 1, n + 1) {
    int t = i % 2;
    int a[4];
    REP(j, 0, 3) { cin >> a[j]; }
    a[3] = 1;
    REP(j, 0, 3 * i + 1) {
      int res = inf;
      REP(k, 0, 4) {
	if (j >= k) {
	  res = min(res, dp[1 - t][j - k] + a[k]);
	}
      }
      dp[t][j] = res;
    }
  }
  printf("%.15f\n", dp[n % 2][p] / 1.0 / n);
}
0