結果

問題 No.472 平均順位
ユーザー prtoq3prtoq3
提出日時 2018-10-06 14:44:18
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 221 ms / 2,000 ms
コード長 799 bytes
コンパイル時間 1,252 ms
コンパイル使用メモリ 158,916 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-20 17:51:34
合計ジャッジ時間 3,043 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 8 ms
5,376 KB
testcase_10 AC 6 ms
5,376 KB
testcase_11 AC 22 ms
5,376 KB
testcase_12 AC 15 ms
5,376 KB
testcase_13 AC 53 ms
5,376 KB
testcase_14 AC 180 ms
5,376 KB
testcase_15 AC 52 ms
5,376 KB
testcase_16 AC 205 ms
5,376 KB
testcase_17 AC 221 ms
5,376 KB
testcase_18 AC 14 ms
5,376 KB
testcase_19 AC 26 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const int MAX_N = 15010;
const int INF = 1<<29;

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)

int a[MAX_N][3];
int dp[MAX_N];
double ans;

int main(){
    int n, p;
    cin >> n >> p;
    for (int i = 0; i < n; i++) cin >> a[i][0] >> a[i][1] >> a[i][2];

    for (int j = 0; j < MAX_N; j++) dp[j] = INF;
    dp[0] = 0;

    for(int i = 0; i < n; i++){
        for (int j = p; j >= 0; j--){
            dp[j] += a[i][0];
            for (int k = 1; k < 3; k++){
                if (j - k >= 0) dp[j] = min(dp[j], dp[j - k] + a[i][k]);
            }
            if (j - 3 >= 0) dp[j] = min(dp[j], dp[j - 3] + 1);
        }
    }

    ans = 1.0 * dp[p] / n;

    cout << ans << endl;    

    return 0;
}
0