結果

問題 No.472 平均順位
ユーザー sugarrrsugarrr
提出日時 2018-01-04 00:24:01
言語 C++11
(gcc 11.4.0)
結果
MLE  
実行時間 -
コード長 984 bytes
コンパイル時間 987 ms
コンパイル使用メモリ 69,244 KB
実行使用メモリ 296,756 KB
最終ジャッジ日時 2023-08-24 18:07:19
合計ジャッジ時間 2,650 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 4 ms
5,356 KB
testcase_09 AC 11 ms
11,308 KB
testcase_10 AC 8 ms
8,488 KB
testcase_11 AC 26 ms
28,340 KB
testcase_12 AC 19 ms
21,052 KB
testcase_13 AC 65 ms
68,844 KB
testcase_14 AC 334 ms
244,248 KB
testcase_15 AC 66 ms
68,832 KB
testcase_16 MLE -
testcase_17 MLE -
testcase_18 AC 18 ms
20,680 KB
testcase_19 AC 34 ms
34,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #



#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
typedef long long ll;
using namespace std;
int min4(int a,int b,int c,int d){
    if(a<b)b=a;
    if(b<c)c=b;
    if(c<d)d=c;
    return d;
}
int min3(int a,int b,int c){
    if(a<b)b=a;
    if(b<c)c=b;
    return c;
}


int main(){
    int n,p;cin>>n>>p;
    int a[n+1],b[n+1],c[n+1];for(int i=1;i<=n;i++)cin>>a[i]>>b[i]>>c[i];
    int dp[n+1][p+1];
    for(int j=0;j<=p;j++)dp[0][j]=0;
    for(int i=1;i<=n;i++)for(int j=0;j<=p;j++){
        if(j==0)dp[i][j]=dp[i-1][j]+a[i];
        else if(j==1)dp[i][j]=min(dp[i-1][j]+a[i],dp[i-1][j-1]+b[i]);
        else if(j==2)dp[i][j]=min3(dp[i-1][j]+a[i],dp[i-1][j-1]+b[i],dp[i-1][j-2]+c[i]);
        else dp[i][j]=min4(dp[i-1][j]+a[i],dp[i-1][j-1]+b[i],dp[i-1][j-2]+c[i],dp[i-1][j-3]+1);
    }
    cout<<(double)dp[n][p]/n<<endl;
    
    
    return 0;
}


0