結果

問題 No.472 平均順位
ユーザー nanophoto12nanophoto12
提出日時 2017-01-01 20:16:09
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 1,237 bytes
コンパイル時間 983 ms
コンパイル使用メモリ 96,224 KB
実行使用メモリ 19,912 KB
最終ジャッジ日時 2023-08-22 09:14:00
合計ジャッジ時間 3,995 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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<ll> dp[4];

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;
    }
    for(int i = 0;i < n+1;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[i+1][j-w] = min(dp[i+1][j-w], c + dp[i][j]);
            }
        }
    }
    ll minc = 1e12;
    for(int i = 0;i <= p;i++)
    {
        minc = min(minc, dp[n][i]);
    }
    cout << fixed << setprecision(8);
    cout << minc / (double)n << endl;
    return 0;
}
0