結果

問題 No.472 平均順位
ユーザー ueckiryuueckiryu
提出日時 2019-07-11 15:25:21
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 245 ms / 2,000 ms
コード長 848 bytes
コンパイル時間 579 ms
コンパイル使用メモリ 65,648 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-25 08:43:11
合計ジャッジ時間 2,076 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 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 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 9 ms
5,376 KB
testcase_10 AC 6 ms
5,376 KB
testcase_11 AC 22 ms
5,376 KB
testcase_12 AC 17 ms
5,376 KB
testcase_13 AC 60 ms
5,376 KB
testcase_14 AC 203 ms
5,376 KB
testcase_15 AC 57 ms
5,376 KB
testcase_16 AC 232 ms
5,376 KB
testcase_17 AC 245 ms
5,376 KB
testcase_18 AC 16 ms
5,376 KB
testcase_19 AC 29 ms
5,376 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[2][P + 1]; //N個目までのコンテストでP問解答した時の順位の和
    for(j = 0; j <= P; j++) {
        dp[0][j] = 1000000;
    }

    dp[0][0] = 0;

    for(i = 0; i < N; i++) {
        for(j = 0; j <= P; j++) {
            dp[1][j] = dp[0][j] + a[i];
            if(j>0)dp[1][j] = min(dp[1][j], dp[0][j - 1] + b[i]);
            if(j>1)dp[1][j] = min(dp[1][j], dp[0][j - 2] + c[i]);
            if(j>2)dp[1][j] = min(dp[1][j], dp[0][j - 3] + 1);
        }

        for(j = 0; j <= P;j++){
            dp[0][j] = dp[1][j];
        }
    }
    printf("%.6f\n",(double)dp[1][P] / N);
    return 0;
}
0