結果

問題 No.472 平均順位
ユーザー sotanakajimacl1sotanakajimacl1
提出日時 2017-09-20 17:38:39
言語 C++11
(gcc 11.4.0)
結果
MLE  
実行時間 -
コード長 1,010 bytes
コンパイル時間 387 ms
コンパイル使用メモリ 57,840 KB
実行使用メモリ 404,648 KB
最終ジャッジ日時 2024-04-25 21:14:07
合計ジャッジ時間 3,434 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 1 ms
6,948 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 4 ms
18,040 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 3 ms
8,092 KB
testcase_07 AC 4 ms
18,040 KB
testcase_08 AC 12 ms
51,072 KB
testcase_09 AC 25 ms
63,024 KB
testcase_10 AC 32 ms
68,200 KB
testcase_11 AC 61 ms
97,652 KB
testcase_12 AC 55 ms
91,640 KB
testcase_13 MLE -
testcase_14 MLE -
testcase_15 MLE -
testcase_16 MLE -
testcase_17 MLE -
testcase_18 AC 38 ms
108,712 KB
testcase_19 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<cstdio>
#define INF (1<<30)
using namespace std;

int n,p,a[5001],b[5001],c[5001];
double dp[5001][15001],ans;//iコンテストまでにj解いた時の平均順位の最低値

int main(){
	cin>>n>>p;
	for(int i=1;i<=n;i++){
		cin>>a[i]>>b[i]>>c[i];
	}
	for(int i=1;i<=n;i++){
		for(int j=0;j<=3*i;j++){
			if(j==0){
				dp[i][j]=(dp[i-1][j]+a[i]);
			}
			else if(j==1){
				dp[i][j]=min((dp[i-1][0]+b[i]),(dp[i-1][1]+a[i]));
			}
			else if(j==2){
				dp[i][j]=min(min((dp[i-1][0]+c[i]),(dp[i-1][1]+b[i])),(dp[i-1][2]+a[i]));
			}
			else if(j==3*i){
				dp[i][j]=(dp[i-1][j-3]+1);
			}
			else if(j==3*i-1){
				dp[i][j]=min((dp[i-1][j-3]+1),(dp[i-1][j-2]+c[i]));
			}
			else if(j==3*i-2){
				dp[i][j]=min(min((dp[i-1][j-3]+1),(dp[i-1][j-2]+c[i])),(dp[i-1][j-1]+b[i]));
			}
			else{
				dp[i][j]=min(min(min(dp[i-1][j-3]+1,dp[i-1][j-2]+c[i]),dp[i-1][j-1]+b[i]),dp[i-1][j]+a[i]);
			}
		}
	}
	ans=(double)dp[n][p]/n;
	
	printf("%.10f\n",ans);
	return 0;
}
0