結果

問題 No.472 平均順位
ユーザー sotanakajimacl1sotanakajimacl1
提出日時 2017-09-20 17:14:24
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 990 bytes
コンパイル時間 525 ms
コンパイル使用メモリ 57,460 KB
実行使用メモリ 280,488 KB
最終ジャッジ日時 2024-04-25 21:13:58
合計ジャッジ時間 1,574 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<algorithm>
#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]);
			}
			else if(j==3*i-1){
				dp[i][j]=min((dp[i-1][j-3]),(dp[i-1][j-2]+c[i]));
			}
			else if(j=3*i-2){
				dp[i][j]=min(min((dp[i-1][j-3]),(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]),(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