結果

問題 No.472 平均順位
ユーザー face4face4
提出日時 2018-11-18 20:13:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 841 bytes
コンパイル時間 610 ms
コンパイル使用メモリ 71,724 KB
実行使用メモリ 589,992 KB
最終ジャッジ日時 2023-08-26 01:59:14
合計ジャッジ時間 4,497 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 4 ms
16,044 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
7,708 KB
testcase_07 AC 5 ms
18,104 KB
testcase_08 AC 15 ms
52,908 KB
testcase_09 AC 37 ms
120,756 KB
testcase_10 AC 47 ms
147,428 KB
testcase_11 AC 83 ms
225,688 KB
testcase_12 AC 73 ms
211,172 KB
testcase_13 MLE -
testcase_14 MLE -
testcase_15 MLE -
testcase_16 MLE -
testcase_17 MLE -
testcase_18 AC 43 ms
145,628 KB
testcase_19 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<iomanip>
using namespace std;

typedef long long ll;

static ll dp[5001][15005];
const ll INF = 1ll<<60;

int main(){
    int n, p;
    cin >> n >> p;

    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= n*3; j++){
            dp[i][j] = INF;
        }
    }

    dp[0][0] = 0;
    
    int a, b, c;

    for(int i = 0; i < n; i++){
        cin >> a >> b >> c;
        for(int j = 0; j <= 3*n; j++){
            if(dp[i][j] != INF){
                dp[i+1][j] = min(dp[i+1][j], dp[i][j] + a);
                dp[i+1][j+1] = min(dp[i+1][j+1], dp[i][j] + b);
                dp[i+1][j+2] = min(dp[i+1][j+2], dp[i][j] + c);
                dp[i+1][j+3] = min(dp[i+1][j+3], dp[i][j] + 1);
            }
        }
    }

    cout << fixed << setprecision(10) << (double)(dp[n][p]) / n << endl;
    return 0;
}
0