結果

問題 No.472 平均順位
ユーザー exaluckexaluck
提出日時 2018-11-14 03:01:33
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 842 bytes
コンパイル時間 2,228 ms
コンパイル使用メモリ 69,332 KB
実行使用メモリ 589,924 KB
最終ジャッジ日時 2023-08-26 01:00:30
合計ジャッジ時間 6,819 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 6 ms
6,464 KB
testcase_09 AC 22 ms
19,004 KB
testcase_10 AC 15 ms
12,740 KB
testcase_11 AC 65 ms
52,660 KB
testcase_12 AC 48 ms
37,816 KB
testcase_13 AC 170 ms
133,668 KB
testcase_14 MLE -
testcase_15 AC 184 ms
133,828 KB
testcase_16 MLE -
testcase_17 MLE -
testcase_18 AC 52 ms
37,060 KB
testcase_19 AC 84 ms
65,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

constexpr long long inf = 1e16;

int main()
{
	int n, p;
	cin >> n >> p;

	vector<vector<int>> rank(n, vector<int>(4, 1));
	for(auto& x : rank) {
		cin >> x[0] >> x[1] >> x[2];
	}

	vector<vector<long long>> dp(n + 1, vector<long long>(p + 1, inf)); 
	for(auto i = 0; i < 4; ++i) {
		dp[1][i] = rank[0][i];
	}
	for(auto i = 2; i <= n; ++i) {
		for(auto j = 0; j <= p; ++j) {
			long long temp1 = dp[i - 1][j] + rank[i - 1][0];
			long long temp2 = j > 0 ? dp[i - 1][j - 1] + rank[i - 1][1] : inf;
			long long temp3 = j > 1 ? dp[i - 1][j - 2] + rank[i - 1][2] : inf;
			long long temp4 = j > 2 ? dp[i - 1][j - 3] + rank[i - 1][3] : inf;
			dp[i][j] = min({temp1, temp2, temp3, temp4});
		}
	}

	cout << static_cast<double>(dp[n][p]) / n << endl;

	return 0;
}
0