結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
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 AC 39 ms
83,876 KB
testcase_18 WA -
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[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