結果

問題 No.472 平均順位
ユーザー face4face4
提出日時 2018-11-18 20:20:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 191 ms / 2,000 ms
コード長 756 bytes
コンパイル時間 745 ms
コンパイル使用メモリ 76,060 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-26 01:59:18
合計ジャッジ時間 2,924 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,384 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 9 ms
4,380 KB
testcase_10 AC 14 ms
4,376 KB
testcase_11 AC 30 ms
4,376 KB
testcase_12 AC 28 ms
4,376 KB
testcase_13 AC 191 ms
4,380 KB
testcase_14 AC 186 ms
4,376 KB
testcase_15 AC 189 ms
4,376 KB
testcase_16 AC 186 ms
4,380 KB
testcase_17 AC 187 ms
4,380 KB
testcase_18 AC 13 ms
4,380 KB
testcase_19 AC 169 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

typedef long long ll;

const ll INF = 1ll<<60;

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

    vector<ll> dp(3*n+5, INF);
    dp[0] = 0;
    
    int a, b, c;

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

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