結果

問題 No.472 平均順位
ユーザー nanophoto12nanophoto12
提出日時 2017-01-01 20:20:45
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 317 ms / 2,000 ms
コード長 1,334 bytes
コンパイル時間 1,025 ms
コンパイル使用メモリ 98,440 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-22 18:43:48
合計ジャッジ時間 3,288 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 4 ms
4,380 KB
testcase_09 AC 11 ms
4,384 KB
testcase_10 AC 8 ms
4,384 KB
testcase_11 AC 30 ms
4,380 KB
testcase_12 AC 22 ms
4,384 KB
testcase_13 AC 75 ms
4,384 KB
testcase_14 AC 260 ms
4,384 KB
testcase_15 AC 75 ms
4,380 KB
testcase_16 AC 298 ms
4,380 KB
testcase_17 AC 317 ms
4,384 KB
testcase_18 AC 21 ms
4,380 KB
testcase_19 AC 38 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>

using namespace std;

#define ll long long int
#define pll pair<double,ll>

vector<vector<ll>> dp;

int main()
{
    int n, p;
    cin >> n >> p;
    vector<int> as[4];
    for(int i = 0;i < 4;i++)
    {
        as[i].resize(n);
    }
    for(int i = 0;i < n;i++)
    {
        cin >> as[0][i] >> as[1][i] >> as[2][i];
        as[3][i] = 1;
    }
    dp.resize(2);
    for(int i = 0;i < 2;i++)
    {
        dp[i].resize(p+1);
        fill(dp[i].begin(), dp[i].end(), (ll)1e12);
    }
    fill(dp[0].begin(), dp[0].end(), 0);
    for(int i = 0;i < n;i++)
    {
        for(int w = 0; w < 4;w++)
        {
            ll c = as[w][i];
            for(int j = w;j <= p;j++)
            {
                dp[1][j-w] = min(dp[1][j-w], c + dp[0][j]);
            }
        }
        swap(dp[0], dp[1]);
        fill(dp[1].begin(), dp[1].end(), (ll)1e12);
    }
    ll minc = 1e12;
    for(int i = 0;i <= p;i++)
    {
        minc = min(minc, dp[0][i]);
    }
    cout << fixed << setprecision(8);
    cout << minc / (double)n << endl;
    return 0;
}
0