結果

問題 No.472 平均順位
ユーザー nxterunxteru
提出日時 2018-06-01 23:02:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 285 ms / 2,000 ms
コード長 560 bytes
コンパイル時間 852 ms
コンパイル使用メモリ 65,900 KB
実行使用メモリ 4,512 KB
最終ジャッジ日時 2023-09-12 21:27:54
合計ジャッジ時間 2,890 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
#define INF 500000001
int n,p;
int dp[15005];
int main(void){
    scanf("%d%d",&n,&p);
    for(int i=0;i<=p;i++)dp[i]=INF;
    dp[0]=0;
    for(int i=0;i<n;i++){
        int a,b,c;
        scanf("%d%d%d",&a,&b,&c);
        for(int j=p;j>=0;j--){
            dp[j]+=a;
            if(j-1>=0)dp[j]=min(dp[j],dp[j-1]+b);
            if(j-2>=0)dp[j]=min(dp[j],dp[j-2]+c);
            if(j-3>=0)dp[j]=min(dp[j],dp[j-3]+1);
        }
    }
    printf("%lf\n",double(dp[p])/double(n));
}
0