結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー Mr.SpockMr.Spock
提出日時 2020-12-15 23:03:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 680 bytes
コンパイル時間 1,533 ms
コンパイル使用メモリ 170,156 KB
実行使用メモリ 4,368 KB
最終ジャッジ日時 2023-10-20 06:52:49
合計ジャッジ時間 7,385 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
4,368 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 126 ms
4,368 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 128 ms
4,368 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 106 ms
4,368 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 109 ms
4,368 KB
testcase_16 AC 123 ms
4,368 KB
testcase_17 AC 124 ms
4,368 KB
testcase_18 AC 124 ms
4,368 KB
testcase_19 AC 128 ms
4,368 KB
testcase_20 AC 128 ms
4,368 KB
testcase_21 AC 127 ms
4,368 KB
testcase_22 AC 113 ms
4,368 KB
testcase_23 AC 118 ms
4,368 KB
testcase_24 AC 2 ms
4,368 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 2 ms
4,368 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
vector<int>v;
int k;
bool ok(double mid) {
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		ans += (v[i] / mid);
	}
	return (ans >= k);
}
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	v.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	cin >> k;
	double long left = 0, right = 1e9 + 1;
	for (int rep = 0; rep < 80; rep++) {
		double long mid = (left + right) / 2.0;
		if (ok(mid))left = mid;
		else right = mid;
	}
	cout << setprecision(9) << fixed << left << endl;
}
0