結果

問題 No.472 平均順位
ユーザー fiordfiord
提出日時 2017-08-14 17:43:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 275 ms / 2,000 ms
コード長 1,678 bytes
コンパイル時間 936 ms
コンパイル使用メモリ 93,384 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 11:25:47
合計ジャッジ時間 2,700 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 9 ms
5,376 KB
testcase_10 AC 6 ms
5,376 KB
testcase_11 AC 24 ms
5,376 KB
testcase_12 AC 17 ms
5,376 KB
testcase_13 AC 63 ms
5,376 KB
testcase_14 AC 226 ms
5,376 KB
testcase_15 AC 62 ms
5,376 KB
testcase_16 AC 257 ms
5,376 KB
testcase_17 AC 275 ms
5,376 KB
testcase_18 AC 18 ms
5,376 KB
testcase_19 AC 33 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <algorithm>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef complex<ld> compd;
#define rep(i,n)	for(int i=0;i<n;i++)
#define srep(i,a,n)	for(int i=a;i<n;i++)
#define REP(i,n)	for(int i=0;i<=n;i++)
#define SREP(i,a,n)	for(int i=a;i<=n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define fst	first
#define scn second
#define bicnt(x)	__buildin__popcount(x)
#define debug(x)	cout<<"debug: "<<x<<endl
#define DEBUG 0

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;
const ld eps = 1e-9;
const int dx[] = { 0,1,0,-1 };
const int dy[] = { 1,0,-1,0 };

int dp[15010],dp2[15010];

int main() {
	int n, p;	cin >> n >> p;
	REP(i, p)	dp[i] = dp2[i] = inf;
	dp[0] = 0;
	rep(i, n) {
		int a, b, c;	cin >> a >> b >> c;
		REP(j, p) {
			if (dp[i] == inf)	continue;
			dp2[j] = min(dp2[j], dp[j] + a);
			if (j + 1 <= p)	dp2[j + 1] = min(dp2[j + 1], dp[j] + b);
			if (j + 2 <= p)	dp2[j + 2] = min(dp2[j + 2], dp[j] + c);
			if (j + 3 <= p)	dp2[j + 3] = min(dp2[j + 3], dp[j] + 1);
		}
		REP(j, p) {
			dp[j] = dp2[j];
			dp2[j] = inf;
		}
	}
	printf("%.15Lf\n", ((ld)dp[p]) / ((ld)n) + eps);
	return 0;
}
0