結果

問題 No.472 平均順位
ユーザー mamekinmamekin
提出日時 2017-06-11 12:43:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 368 ms / 2,000 ms
コード長 1,000 bytes
コンパイル時間 848 ms
コンパイル使用メモリ 104,236 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 20:56:06
合計ジャッジ時間 3,326 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 4 ms
4,348 KB
testcase_09 AC 12 ms
4,348 KB
testcase_10 AC 9 ms
4,348 KB
testcase_11 AC 34 ms
4,348 KB
testcase_12 AC 24 ms
4,348 KB
testcase_13 AC 87 ms
4,348 KB
testcase_14 AC 307 ms
4,348 KB
testcase_15 AC 91 ms
4,348 KB
testcase_16 AC 356 ms
4,348 KB
testcase_17 AC 368 ms
4,348 KB
testcase_18 AC 24 ms
4,348 KB
testcase_19 AC 45 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

const int INF = INT_MAX / 2;

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

    vector<int> dp(p+1, INF);
    dp[p] = 0;
    for(int i=0; i<n; ++i){
        vector<int> v(4, 1);
        for(int i=0; i<3; ++i)
            cin >> v[i];

        vector<int> nextDp(p+1, INF);
        for(int j=0; j<=p; ++j){
            for(int k=0; k<=min(3,j); ++k){
                nextDp[j-k] = min(nextDp[j-k], dp[j] + v[k]);
            }
        }
        dp.swap(nextDp);
    }

    double ans = dp[0] / (double)n;
    printf("%.10f\n", ans);

    return 0;
}
0