結果
| 問題 |
No.67 よくある棒を切る問題 (1)
|
| コンテスト | |
| ユーザー |
kyuna
|
| 提出日時 | 2019-08-11 02:53:46 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 742 bytes |
| コンパイル時間 | 756 ms |
| コンパイル使用メモリ | 74,680 KB |
| 実行使用メモリ | 8,612 KB |
| 最終ジャッジ日時 | 2025-03-03 11:26:21 |
| 合計ジャッジ時間 | 7,959 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 9 RE * 21 |
ソースコード
#include <algorithm>
#include <iostream>
#include <vector>
#include <cassert>
using namespace std;
using ll = long long;
vector<int> ls;
ll k;
bool check(double x) {
ll cnt = 0;
for (int l: ls) cnt += l / x;
return cnt >= k;
}
double binary_search(double ok, double ng) {
assert(check(ok) == true);
assert(check(ng) == false);
for (int i = 0; i < 100; i++) {
double mid = (ng + ok) / 2;
(check(mid) ? ok : ng) = mid;
}
return ok;
}
#include <iomanip>
int main() {
cout << fixed << setprecision(12);
int n; cin >> n;
ls.resize(n);
for (int &l: ls) cin >> l;
cin >> k;
double ok = n / k;
double ng = 1e12;
cout << binary_search(ok, ng) << endl;
return 0;
}
kyuna