結果

問題 No.472 平均順位
ユーザー hiromi-mi
提出日時 2018-12-30 22:45:29
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
MLE  
実行時間 -
コード長 1,027 bytes
コンパイル時間 666 ms
コンパイル使用メモリ 64,416 KB
実行使用メモリ 299,692 KB
最終ジャッジ日時 2024-10-09 05:22:25
合計ジャッジ時間 3,482 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 10 MLE * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <cmath>
/*
#include <map>
#include <functional>
#include <set>
#include <queue>
#include <cstdio>
*/
using namespace std;
typedef long long ll;
//typedef pair<ll, ll> P;

int N, P;
int a[5050], b[5050], c[5050];

// コンテストi までにj問題といたときの順位の合計
int dp[5050][15050];
const int INF = 1 << 30;
#define abc(i, j, k) ((j >= 0 && dp[i][j] < INF) ? (dp[i][j] + k) : (INF))

int main() {
   cin >> N >> P;
   for (int i=0;i<N;i++) {
      cin >> a[i] >> b[i] >> c[i];
   }
   for (int i=0;i<=N;i++) {
      for (int j=0;j<=N*3;j++) {
         dp[i][j] = INF;
      }
   }
   dp[0][0] = 0;
   for (int i=0;i<N;i++) {
      for (int j=0;j<=P;j++) {
         dp[i+1][j] = min({abc(i, j, a[i]),
                           abc(i, j-1, b[i]),
                           abc(i, j-2, c[i]),
                           abc(i, j-3, 1)});
      }
   }
   cout << (double)dp[N][P] / (double)N << endl;
}
0