結果

問題 No.472 平均順位
ユーザー exaluckexaluck
提出日時 2018-11-14 03:23:30
言語 C++11
(gcc 11.4.0)
結果
MLE  
実行時間 -
コード長 891 bytes
コンパイル時間 581 ms
コンパイル使用メモリ 67,272 KB
実行使用メモリ 589,948 KB
最終ジャッジ日時 2023-08-26 01:00:43
合計ジャッジ時間 4,686 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 7 ms
6,396 KB
testcase_09 AC 25 ms
18,852 KB
testcase_10 AC 18 ms
12,852 KB
testcase_11 AC 76 ms
53,020 KB
testcase_12 AC 54 ms
37,856 KB
testcase_13 AC 204 ms
134,028 KB
testcase_14 MLE -
testcase_15 WA -
testcase_16 MLE -
testcase_17 MLE -
testcase_18 AC 50 ms
37,280 KB
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using namespace std;

constexpr long long inf = 1e8;

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

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

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

	cout << 1.0 * dp[n][p] / n << endl;

	return 0;
}
0