結果

問題 No.472 平均順位
ユーザー _3_72__3_72_
提出日時 2019-08-28 20:37:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 233 ms / 2,000 ms
コード長 1,577 bytes
コンパイル時間 1,578 ms
コンパイル使用メモリ 168,396 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-28 20:50:41
合計ジャッジ時間 3,190 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 3 ms
5,376 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 9 ms
5,376 KB
testcase_10 AC 7 ms
5,376 KB
testcase_11 AC 23 ms
5,376 KB
testcase_12 AC 17 ms
5,376 KB
testcase_13 AC 56 ms
5,376 KB
testcase_14 AC 191 ms
5,376 KB
testcase_15 AC 57 ms
5,376 KB
testcase_16 AC 219 ms
5,376 KB
testcase_17 AC 233 ms
5,376 KB
testcase_18 AC 17 ms
5,376 KB
testcase_19 AC 30 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
// #define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
//----------------------------------------------------------------

// int MOD = 998244353;
int MOD = 1000000007;

int dp[2][15001] = {0};

//----------------------------------------------------------------
signed main(){

	ll n,p;
	cin >> n >> p;

	vector<int> a(n),b(n),c(n);
	rep(i,n) cin >> a[i] >> b[i] >> c[i];

	for(int i = 0;i < n;i++){
		for(int j = 0;j <= p;j++){
			dp[(i+1)%2][j] = dp[i%2][j] + a[i];
			if(j >= 1) dp[(i+1)%2][j] = min(dp[(i+1)%2][j],dp[i%2][j-1]+b[i]);
			if(j >= 2) dp[(i+1)%2][j] = min(dp[(i+1)%2][j],dp[i%2][j-2]+c[i]);
			if(j >= 3) dp[(i+1)%2][j] = min(dp[(i+1)%2][j],dp[i%2][j-3]+1);
		}
	}

	// cout << dp[n][p]*1.0/n << endl;
	printf("%0.10lf\n",dp[n%2][p]*1.0/n);
	

	return 0;
}

//----------------------------------------------------------------

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://dp.contest.atcoder.jp/tasks/dp_a
// rm -r -f test;oj dl https://abc054.contest.atcoder.jp/tasks/abc054_d
0