結果

問題 No.472 平均順位
ユーザー okok
提出日時 2018-09-23 12:33:42
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 111 ms / 2,000 ms
コード長 829 bytes
コンパイル時間 457 ms
コンパイル使用メモリ 65,784 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-11 21:01:56
合計ジャッジ時間 2,090 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,352 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,352 KB
testcase_08 AC 3 ms
4,352 KB
testcase_09 AC 7 ms
4,348 KB
testcase_10 AC 9 ms
4,352 KB
testcase_11 AC 18 ms
4,356 KB
testcase_12 AC 17 ms
4,348 KB
testcase_13 AC 111 ms
4,348 KB
testcase_14 AC 109 ms
4,348 KB
testcase_15 AC 110 ms
4,348 KB
testcase_16 AC 109 ms
4,352 KB
testcase_17 AC 110 ms
4,348 KB
testcase_18 AC 9 ms
4,348 KB
testcase_19 AC 99 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include <iomanip>
#include<algorithm>
#define MAX_P 15010
#define INF (long long)1e13


int main(){
	std::cout<<std::fixed<<std::setprecision(6);
	long long dp[2][MAX_P];
	int N, P, a, b, c;
	std::cin>>N>>P;
	
	for(int j = 0; j <= P; j++)dp[0][j]=dp[1][j]=INF;
	
	dp[1][0] = 0;
	
	for(int i = 0; i < N; i++){
		std::cin>>a>>b>>c;
		for(int j = 0; j <= i*3; j++){
			if(dp[(i+1)%2][j] == INF) continue;
			dp[i%2][j]   = std::min(dp[(i+1)%2][j]+a,dp[i%2][j]  );
			dp[i%2][j+1] = std::min(dp[(i+1)%2][j]+b,dp[i%2][j+1]);
			dp[i%2][j+2] = std::min(dp[(i+1)%2][j]+c,dp[i%2][j+2]);
			dp[i%2][j+3] = std::min(dp[(i+1)%2][j]+1,dp[i%2][j+3]);
			dp[(i+1)%2][j] = INF;
		}
		// for(int j = 0; j <= P; j++)std::cout<<j<<" "<<dp[i%2][j]<<std::endl;
	}
	
	std::cout<<(double)dp[(N-1)%2][P]/N<<std::endl;
	
	return 0;
}
0