結果
| 問題 |
No.67 よくある棒を切る問題 (1)
|
| コンテスト | |
| ユーザー |
not_522
|
| 提出日時 | 2015-08-17 12:45:22 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 360 ms / 5,000 ms |
| コード長 | 644 bytes |
| コンパイル時間 | 1,349 ms |
| コンパイル使用メモリ | 159,764 KB |
| 実行使用メモリ | 8,604 KB |
| 最終ジャッジ日時 | 2025-03-03 10:22:37 |
| 合計ジャッジ時間 | 10,354 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 30 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
template<typename Function> long double bisectionMethod(Function function, long double lower, long double upper) {
for (int i = 0; i < 200; ++i) {
long double middle = (lower + upper) / 2;
(function(middle) <= 0 ? lower : upper) = middle;
}
return lower;
}
int main() {
int n;
cin >> n;
vector<int> l(n);
for (int& i : l) cin >> i;
long long k;
cin >> k;
auto f = [&](double x){
long long sum = 0;
for (int& i : l) sum += floor(i / x);
return sum - k + 0.5;
};
cout << fixed << setprecision(15) << bisectionMethod(f, numeric_limits<int>::max(), 0);
}
not_522