結果

問題 No.472 平均順位
ユーザー mogurockermogurocker
提出日時 2017-10-14 18:24:18
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 445 ms / 2,000 ms
コード長 809 bytes
コンパイル時間 1,307 ms
コンパイル使用メモリ 159,088 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-28 19:38:48
合計ジャッジ時間 3,637 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 4 ms
5,376 KB
testcase_09 AC 14 ms
5,376 KB
testcase_10 AC 9 ms
5,376 KB
testcase_11 AC 40 ms
5,376 KB
testcase_12 AC 28 ms
5,376 KB
testcase_13 AC 100 ms
5,376 KB
testcase_14 AC 365 ms
5,376 KB
testcase_15 AC 100 ms
5,376 KB
testcase_16 AC 417 ms
5,376 KB
testcase_17 AC 445 ms
5,376 KB
testcase_18 AC 27 ms
5,376 KB
testcase_19 AC 50 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int n, p, dp[15005];
const int INF = 1000000007;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n >> p;
	// FOR(i, n+1) FOR(j, 3*n+1) dp[i][j] = INF;
	fill(dp, dp+3*n+1, INF);
	FOR(i, n) {
		int v[4];
		FOR(k, 3) cin >> v[k];
		v[3] = 1;
		if (i == 0) {
			FOR(k, 4) dp[k] = v[k];
		}
		else {
			vector<int> x(p+1);
			FOR(i, p+1) x[i] = INF;
			FOR(j, p+1) {
				FOR(k, 4) {
					if (j+k <= p) x[j+k] = min(x[j+k], dp[j]+v[k]);
				}
			}
			FOR(j, p+1) dp[j] = x[j];
		}

	}
	printf("%.10lf\n", dp[p]/(double)n);
	return 0;
}
0