結果

問題 No.472 平均順位
ユーザー RyuRyu
提出日時 2018-01-21 18:07:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 548 ms / 2,000 ms
コード長 1,101 bytes
コンパイル時間 1,037 ms
コンパイル使用メモリ 80,784 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-26 19:50:43
合計ジャッジ時間 3,967 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 5 ms
4,376 KB
testcase_09 AC 17 ms
4,380 KB
testcase_10 AC 12 ms
4,380 KB
testcase_11 AC 49 ms
4,376 KB
testcase_12 AC 35 ms
4,380 KB
testcase_13 AC 125 ms
4,380 KB
testcase_14 AC 451 ms
4,380 KB
testcase_15 AC 126 ms
4,380 KB
testcase_16 AC 518 ms
4,376 KB
testcase_17 AC 548 ms
4,380 KB
testcase_18 AC 34 ms
4,376 KB
testcase_19 AC 62 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <numeric>
#include <cstring>
#include <cmath>
#include <set>
#include <queue>
#include <stack>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using edge = struct
{
    int to;
    int cost;
};

int dp[2][15010];
int s[5010][4];

int main()
{
    int N, P;
    cin >> N >> P;

    rep(i, N)
    {
        cin >> s[i][0] >> s[i][1] >> s[i][2];
        s[i][3] = 1;
    }

    rep(i, 2) rep(j, 15010) dp[i][j] = iINF;

    dp[0][0] = 0;

    rep(i, N)
    {
        rep(j, (P + 1))
        {
            rep(k, 4)
            {
                if (k + j <= P)
                    dp[1][j + k] = min(dp[0][j] + s[i][k], dp[1][j + k]);
            }
        }

        rep(j, P + 1)
        {
            dp[0][j] = dp[1][j];
            dp[1][j] = iINF;
        }
    }

    printf("%0.9f\n", (double)dp[0][P] / (double)N);
}
0