結果

問題 No.472 平均順位
ユーザー shossiissohs
提出日時 2018-01-09 18:20:56
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
MLE  
実行時間 -
コード長 659 bytes
コンパイル時間 1,599 ms
コンパイル使用メモリ 158,296 KB
実行使用メモリ 296,960 KB
最終ジャッジ日時 2024-12-23 14:26:14
合計ジャッジ時間 4,109 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 13 MLE * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int n,p;
int abc[5005][4];
int dp[5005][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;
  }
  for(int i = 0; i <= n; i++) {
    for(int j = 0; j <=p; j++) {
	dp[i][j]= INF;
      }
    }
  

  dp[0][0] = 0;

  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;
	dp[i+1][j+k] = min(dp[i+1][j+k],dp[i][j] + abc[i][k]);
      }
    }
  }

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