結果

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

テストケース

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

ソースコード

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