結果

問題 No.472 平均順位
ユーザー shossiissohsshossiissohs
提出日時 2018-01-09 19:00:47
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,248 ms / 2,000 ms
コード長 655 bytes
コンパイル時間 1,106 ms
コンパイル使用メモリ 145,276 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-25 02:23:12
合計ジャッジ時間 6,524 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 8 ms
4,380 KB
testcase_09 AC 33 ms
4,380 KB
testcase_10 AC 22 ms
4,376 KB
testcase_11 AC 98 ms
4,380 KB
testcase_12 AC 70 ms
4,376 KB
testcase_13 AC 258 ms
4,376 KB
testcase_14 AC 989 ms
4,380 KB
testcase_15 AC 259 ms
4,384 KB
testcase_16 AC 1,163 ms
4,380 KB
testcase_17 AC 1,248 ms
4,380 KB
testcase_18 AC 71 ms
4,376 KB
testcase_19 AC 127 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int n,p;
int abc[5005][4];
int dp[15005];
int dpn[15005];
const int INF = 1e9;
int main() {
  cin >> n >> p;
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < 3; j++) {
      cin >> abc[i][j];
    }
    abc[i][3] = 1;
  }
    
  fill(dpn,dpn+p+1,INF);
  
  for(int i = 0; i < n; i++) {
    for(int j = 0; j <= p; j++) {
      for(int k = 0; k < 4; k++) {
	if(j + k > p) continue;
	dpn[j+k] = min(dpn[j+k], dp[j] + abc[i][k]);
      }
    
    }
      for(int k = 0; k <= p; k++) {
	swap(dpn[k],dp[k]);
	dpn[k] = INF;
    }
  }

  cout << fixed << setprecision(6) << dp[p] / (double)n << endl;
}
  
    
0