結果

問題 No.472 平均順位
ユーザー azbrugbyazbrugby
提出日時 2019-03-01 18:43:56
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 468 ms / 2,000 ms
コード長 1,401 bytes
コンパイル時間 675 ms
コンパイル使用メモリ 74,100 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-05 16:40:30
合計ジャッジ時間 5,135 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 11 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 6 ms
4,376 KB
testcase_07 AC 12 ms
4,376 KB
testcase_08 AC 35 ms
4,380 KB
testcase_09 AC 82 ms
4,376 KB
testcase_10 AC 101 ms
4,380 KB
testcase_11 AC 157 ms
4,376 KB
testcase_12 AC 146 ms
4,376 KB
testcase_13 AC 450 ms
4,380 KB
testcase_14 AC 451 ms
4,380 KB
testcase_15 AC 447 ms
4,376 KB
testcase_16 AC 451 ms
4,380 KB
testcase_17 AC 468 ms
4,380 KB
testcase_18 AC 98 ms
4,380 KB
testcase_19 AC 415 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <cstring>
#include <sstream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <stack>
#include <cstdio>
#include <cmath>
#define mk make_pair
#define pb push_back
#define scanf scanf_s
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pos;
const ll MOD = 1000000007, N = 5001, dx[4] = { -1,1,0,0 }, dy[4] = { 0,0,-1,1 }, MIN = -72340172838, MAX = 72340172838;

ll mn(ll a, ll b) {
	if (a == -1)return b;
	if (b == -1)return a;
	return min(a, b);
}
ll gcd(ll v1, ll v2) {
	if (v1 == 0)return v2; if (v2 == 0)return v1; if (v2 > v1)return gcd(v2%v1, v1); return gcd(v1%v2, v2);
}

ll pw(ll v1, ll v2) {
	ll v3 = 1;
	while (v2 > 0) {
		if (v2 % 2)v3 = (v3*v1) % MOD;
		v1 = (v1*v1) % MOD;
		v2 /= 2;
	}
	return v3;
}

struct ab {
	ll a, b;
	bool operator<(const ab& right) const {
		return right.b*a - right.a*b < 0;
	}
};
ll n, p, dp[N * 3], nv;


int main() {
	cin >> n >> p; nv = n;
	memset(dp, -1, sizeof(dp));
	n--;
	cin >> dp[0] >> dp[1] >> dp[2]; dp[3] = 1;
	while (n--) {
		ll v[4]; cin >> v[0] >> v[1] >> v[2]; v[3] = 1;
		for (int i= N * 3 - 1; i >= 0; i--) {
			ll v1 = dp[i];
			if (v1 != -1)
				dp[i] = v1 + v[0];
			for (int j = 1; j <= 3&&i-j>=0; j++) {
				if (dp[i - j] == -1)continue;
				dp[i] = mn(dp[i], dp[i - j] + v[j]);
			}
		}
	}
	printf("%.10lf\n", (double)dp[p] / nv);
	return 0;
}
0