結果

問題 No.472 平均順位
ユーザー ueckiryuueckiryu
提出日時 2019-07-11 15:21:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 851 bytes
コンパイル時間 481 ms
コンパイル使用メモリ 66,164 KB
実行使用メモリ 296,832 KB
最終ジャッジ日時 2024-04-25 08:37:11
合計ジャッジ時間 2,674 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 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 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 4 ms
5,376 KB
testcase_09 AC 13 ms
11,520 KB
testcase_10 AC 9 ms
8,448 KB
testcase_11 AC 35 ms
28,416 KB
testcase_12 AC 26 ms
21,248 KB
testcase_13 AC 94 ms
68,736 KB
testcase_14 AC 343 ms
244,224 KB
testcase_15 AC 93 ms
68,992 KB
testcase_16 MLE -
testcase_17 MLE -
testcase_18 AC 26 ms
20,864 KB
testcase_19 AC 47 ms
34,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>

using namespace std;

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

    int dp[N + 1][P + 1]; //N個目までのコンテストでP問解答した時の順位の和
    for(i = 0; i <= N; i++) {
        for(j = 0; j <= P; j++) {
            dp[i][j] = 1000000;
        }
    }
    dp[0][0] = 0;

    for(i = 0; i < N; i++) {
        for(j = 0; j <= P; j++) {
            dp[i + 1][j] = dp[i][j] + a[i];
            if(j>0)dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - 1] + b[i]);
            if(j>1)dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - 2] + c[i]);
            if(j>2)dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - 3] + 1);
        }
    }
    printf("%.6f\n",(double)dp[N][P] / N);
    return 0;
}
0