結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 2 ms
4,352 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,352 KB
testcase_06 AC 2 ms
4,352 KB
testcase_07 AC 3 ms
4,352 KB
testcase_08 AC 3 ms
4,352 KB
testcase_09 AC 8 ms
4,352 KB
testcase_10 AC 7 ms
4,352 KB
testcase_11 AC 21 ms
4,352 KB
testcase_12 AC 17 ms
4,352 KB
testcase_13 AC 63 ms
4,356 KB
testcase_14 AC 162 ms
4,372 KB
testcase_15 AC 64 ms
4,352 KB
testcase_16 AC 172 ms
4,356 KB
testcase_17 AC 176 ms
4,352 KB
testcase_18 AC 13 ms
4,352 KB
testcase_19 AC 34 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 < MAX_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 <= P; 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