結果

問題 No.472 平均順位
ユーザー KhiromuKhiromu
提出日時 2017-03-30 18:10:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 864 bytes
コンパイル時間 651 ms
コンパイル使用メモリ 67,748 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-21 08:44:51
合計ジャッジ時間 3,485 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 4 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 5 ms
4,376 KB
testcase_08 AC 13 ms
4,376 KB
testcase_09 AC 33 ms
4,376 KB
testcase_10 WA -
testcase_11 AC 70 ms
4,380 KB
testcase_12 AC 61 ms
4,380 KB
testcase_13 WA -
testcase_14 AC 335 ms
4,376 KB
testcase_15 WA -
testcase_16 AC 365 ms
4,376 KB
testcase_17 AC 376 ms
4,380 KB
testcase_18 AC 45 ms
4,380 KB
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
using namespace std;
#define FOR(i, a, n) for(int i=a; i<n; i++)
#define RFOR(i, a, n) for(int i=n-1; i>=a; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define LL long long
#define INF 10000000

LL dp_from[15001];
LL dp_to[15001];
int main()
{
	int N, P;
	int a[5001], b[5001], c[5001];
	cin >> N >> P;
	REP(i, N) cin >> a[i] >> b[i] >> c[i];
	REP(i, 3 * N + 1) dp_from[i] = INF;

	dp_from[P] = 0;
	REP(i, N) {
		REP(j, 3 * N + 1) dp_to[j] = INF;
		REP(j, P + 1) {
			if (j >= 3) dp_to[j - 3] = min(dp_to[j - 3], dp_from[j] + 1);
			if (j >= 2) dp_to[j - 2] = min(dp_to[j - 2], dp_from[j] + c[i]);
			if (j >= 1) dp_to[j - 1] = min(dp_to[j - 1], dp_from[j] + b[i]);
			dp_to[j] = min(dp_to[j], dp_from[j] + a[i]);
		}
		swap(dp_from, dp_to);
	}

	printf("%.6lf\n", dp_from[0] * 1.0 / N);
	return 0;
}
0