結果

問題 No.472 平均順位
ユーザー syake_tasyake_ta
提出日時 2018-08-25 15:09:24
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 411 ms / 2,000 ms
コード長 845 bytes
コンパイル時間 548 ms
コンパイル使用メモリ 67,792 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-08 10:10:44
合計ジャッジ時間 2,854 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 4 ms
4,380 KB
testcase_09 AC 13 ms
4,380 KB
testcase_10 AC 9 ms
4,376 KB
testcase_11 AC 36 ms
4,376 KB
testcase_12 AC 26 ms
4,380 KB
testcase_13 AC 91 ms
4,380 KB
testcase_14 AC 340 ms
4,376 KB
testcase_15 AC 92 ms
4,376 KB
testcase_16 AC 389 ms
4,380 KB
testcase_17 AC 411 ms
4,376 KB
testcase_18 AC 25 ms
4,376 KB
testcase_19 AC 46 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const int INF = (int)1e9 + 1;

int n, p;
int dp[2][20010];
int score[5010][5];

int main(void) {
	cin >> n >> p;
	for (int i = 0; i < n; i++) {
		cin >> score[i][0] >> score[i][1] >> score[i][2];
		score[i][3] = 1;
	}

	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 20010; j++) {
			dp[i][j] = INF;
		}
	}
	dp[0][0] = 0;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= p; j++) {
			for (int k = 0; k <= 3; k++) {
				if (j + k <= p) {
					dp[1][j + k] = min(dp[1][j + k], dp[0][j] + score[i][k]);
				}
			}
		}
		for (int j = 0; j <= p; j++) {
			dp[0][j] = dp[1][j];
			dp[1][j] = INF;
		}
	}

	cout << fixed << setprecision(9) << (double)dp[0][p] / (double)n << endl;
	return 0;
}
0