結果

問題 No.472 平均順位
ユーザー KhiromuKhiromu
提出日時 2017-03-30 17:37:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 846 bytes
コンパイル時間 469 ms
コンパイル使用メモリ 67,000 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-09-21 08:43:55
合計ジャッジ時間 4,523 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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 INF 10000000

int dp_from[15001];
int 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