結果

問題 No.472 平均順位
ユーザー Div9851Div9851
提出日時 2017-10-05 21:32:49
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 212 ms / 2,000 ms
コード長 851 bytes
コンパイル時間 1,276 ms
コンパイル使用メモリ 158,308 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-28 07:51:59
合計ジャッジ時間 2,810 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 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 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 8 ms
5,376 KB
testcase_10 AC 6 ms
5,376 KB
testcase_11 AC 21 ms
5,376 KB
testcase_12 AC 16 ms
5,376 KB
testcase_13 AC 54 ms
5,376 KB
testcase_14 AC 170 ms
5,376 KB
testcase_15 AC 52 ms
5,376 KB
testcase_16 AC 205 ms
5,376 KB
testcase_17 AC 212 ms
5,376 KB
testcase_18 AC 15 ms
5,376 KB
testcase_19 AC 29 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define MP(a,b) make_pair(a,b)
typedef long long LL;
typedef pair<int, int> PI;
typedef vector<int> VI;
const LL MOD = 1000000007LL;
int dp[15001];
int a[5000], b[5000], c[5000];
int main() {
	int N, P;
	cin >> N >> P;
	rep(i, N) {
		cin >> a[i] >> b[i] >> c[i];
	}
	fill(dp, dp + 15001, 1 << 30);
	dp[0] = 0;
	rep(i, N) {
		for (int j = P; j >= 0; j--) {
			int nxt = 1 << 30;
			if(dp[j]!=1<<30) nxt = min(nxt, dp[j] + a[i]);
			if (j >= 1 && dp[j-1]!=1<<30) nxt = min(nxt, dp[j - 1] + b[i]);
			if (j >= 2 && dp[j-2]!=1<<30) nxt = min(nxt, dp[j - 2] + c[i]);
			if (j >= 3 && dp[j-3]!=1<<30) nxt = min(nxt, dp[j - 3] + 1);
			dp[j] = nxt;
		}
	}
	printf("%.15lf\n", (double)dp[P] / N);
}
0