結果

問題 No.472 平均順位
ユーザー hiromi-mihiromi-mi
提出日時 2018-12-30 22:44:55
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,056 bytes
コンパイル時間 645 ms
コンパイル使用メモリ 64,540 KB
実行使用メモリ 297,856 KB
最終ジャッジ日時 2024-04-17 11:15:18
合計ジャッジ時間 4,371 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 MLE -
testcase_14 MLE -
testcase_15 MLE -
testcase_16 MLE -
testcase_17 MLE -
testcase_18 WA -
testcase_19 MLE -
権限があれば一括ダウンロードができます

ソースコード

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 << dp[N][P] << endl;
   cout << (double)dp[N][P] / (double)N << endl;
}
0