結果

問題 No.472 平均順位
ユーザー hiromi-mihiromi-mi
提出日時 2018-12-30 22:47:37
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 392 ms / 2,000 ms
コード長 969 bytes
コンパイル時間 539 ms
コンパイル使用メモリ 64,436 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-17 11:19:45
合計ジャッジ時間 2,667 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 5 ms
5,376 KB
testcase_09 AC 12 ms
5,376 KB
testcase_10 AC 9 ms
5,376 KB
testcase_11 AC 35 ms
5,376 KB
testcase_12 AC 25 ms
5,376 KB
testcase_13 AC 90 ms
5,376 KB
testcase_14 AC 323 ms
5,376 KB
testcase_15 AC 90 ms
5,376 KB
testcase_16 AC 361 ms
5,376 KB
testcase_17 AC 392 ms
5,376 KB
testcase_18 AC 26 ms
5,376 KB
testcase_19 AC 46 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

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[15050];
const int INF = 1 << 30;
#define abc(i, j, k) ((j >= 0 && dp[j] < INF) ? (dp[j] + k) : (INF))

int main() {
   cin >> N >> P;
   for (int i=0;i<N;i++) {
      cin >> a[i] >> b[i] >> c[i];
   }

      for (int j=0;j<=N*3;j++) {
         dp[j] = INF;
      }
   dp[0] = 0;
   for (int i=0;i<N;i++) {
      for (int j=P;j>=0;j--) {
         dp[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[P] / (double)N << endl;
}
0