結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー ant2357ant2357
提出日時 2017-09-28 23:24:13
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,407 bytes
コンパイル時間 2,129 ms
コンパイル使用メモリ 204,616 KB
実行使用メモリ 8,448 KB
最終ジャッジ日時 2024-04-27 15:14:24
合計ジャッジ時間 6,575 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 112 ms
8,188 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 104 ms
8,068 KB
testcase_18 AC 97 ms
8,064 KB
testcase_19 AC 123 ms
8,060 KB
testcase_20 AC 120 ms
8,192 KB
testcase_21 AC 117 ms
8,192 KB
testcase_22 AC 92 ms
7,752 KB
testcase_23 AC 97 ms
7,916 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"

using namespace std;

using ll = long long int;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vs = vector<string>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, 1, 0, -1 };

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

bool check(ll n, vl l, ll k, ld mid) {
	ll sum = 0;
	for (auto v : l) {
		sum += (ld)v / mid;
		if (sum >= k) {
			return true;
		}
	}
	return false;
}

double solve(ll n, vl l, ll k) {
	ld left = 0.0, right = 10000000001.0;

	int cnt = 0;
	while (left < right - 1.0) {
		ld mid = (left + right) / 2.0;
		if (check(n, l, k, mid)) {
			left = mid;
		} else {
			right = mid;
		}
	}

	return left;
}

int main() {
	/*ios::sync_with_stdio(false);
	cin.tie(0);*/

	ll n;
	cin >> n;

	vl l(n);
	for (int i = 0; i < n; i++) {
		cin >> l[i];
	}

	ll k;
	cin >> k;
	cout << fixed << setprecision(15) << solve(n, l, k) << endl;
	return 0;
}
0