結果

問題 No.472 平均順位
ユーザー fine
提出日時 2017-03-12 20:01:42
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 257 ms / 2,000 ms
コード長 563 bytes
コンパイル時間 1,503 ms
コンパイル使用メモリ 166,788 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-30 00:34:08
合計ジャッジ時間 3,228 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

const int INF = 1e9;

int r[5010][4], dp[15010];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, p;
	cin >> n >> p;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> r[i][j];
		}
		r[i][3] = 1;
	}

	for (int i = 0; i < n; i++) {
		for (int j = p; j >= 0; j--) {
			dp[j] += r[i][0];
			for (int k = 3; k > 0; k--) {
				if (j < k) continue;
				dp[j] = min(dp[j], dp[j - k] + r[i][k]);
			}
		}
	}
	cout << fixed << setprecision(10) << (double)dp[p] / n << endl;
	return 0;
}
0