結果

問題 No.472 平均順位
ユーザー 👑 はまやんはまやんはまやんはまやん
提出日時 2017-03-09 12:14:50
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 381 ms / 2,000 ms
コード長 767 bytes
コンパイル時間 1,599 ms
コンパイル使用メモリ 164,744 KB
実行使用メモリ 5,280 KB
最終ジャッジ日時 2023-09-06 05:13:41
合計ジャッジ時間 5,144 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,268 KB
testcase_01 AC 3 ms
5,076 KB
testcase_02 AC 3 ms
5,076 KB
testcase_03 AC 3 ms
5,244 KB
testcase_04 AC 8 ms
5,144 KB
testcase_05 AC 4 ms
5,076 KB
testcase_06 AC 6 ms
5,104 KB
testcase_07 AC 9 ms
5,064 KB
testcase_08 AC 24 ms
5,228 KB
testcase_09 AC 55 ms
5,020 KB
testcase_10 AC 65 ms
5,068 KB
testcase_11 AC 107 ms
5,280 KB
testcase_12 AC 99 ms
5,008 KB
testcase_13 AC 281 ms
5,088 KB
testcase_14 AC 362 ms
5,072 KB
testcase_15 AC 281 ms
5,064 KB
testcase_16 AC 377 ms
5,060 KB
testcase_17 AC 381 ms
5,128 KB
testcase_18 AC 69 ms
5,124 KB
testcase_19 AC 246 ms
5,260 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)





int N, P;
#define INF INT_MAX/2
int dp[2][201010];
//-----------------------------------------------------------------
int main() {
	cin >> N >> P;

	rep(i, 0, 2) rep(j, 0, 201010) dp[i][j] = INF;
	dp[0][0] = 0;

	rep(_i, 0, N) {
		int i = _i % 2;
		int ii = (_i + 1) % 2;

		rep(j, 0, 201010) dp[ii][j] = INF;

		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);

		rep(j, 0, P + 1) if (dp[i][j] != INF) {
			dp[ii][j + 3] = min(dp[ii][j + 3], dp[i][j] + 1);
			dp[ii][j + 2] = min(dp[ii][j + 2], dp[i][j] + c);
			dp[ii][j + 1] = min(dp[ii][j + 1], dp[i][j] + b);
			dp[ii][j] = min(dp[ii][j], dp[i][j] + a);
		}
	}

	double ans = 1.0 * dp[N % 2][P] / N;
	printf("%.10f\n", ans);
}
0