結果
| 問題 |
No.67 よくある棒を切る問題 (1)
|
| コンテスト | |
| ユーザー |
data9824
|
| 提出日時 | 2015-06-20 05:13:56 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 150 ms / 5,000 ms |
| コード長 | 774 bytes |
| コンパイル時間 | 590 ms |
| コンパイル使用メモリ | 76,580 KB |
| 実行使用メモリ | 8,608 KB |
| 最終ジャッジ日時 | 2025-03-03 10:19:36 |
| 合計ジャッジ時間 | 4,822 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 30 |
ソースコード
#include <iostream>
#include <cmath>
#include <vector>
#include <iomanip>
#include <algorithm>
using namespace std;
const double EPS = 1E-10;
int main() {
int n;
cin >> n;
vector<double> l(n);
for (int i = 0; i < n; ++i) {
cin >> l[i];
}
long long k;
cin >> k;
double lower = 0, upper = *max_element(l.begin(), l.end());
double preLength = 0.0;
while (upper - lower > EPS || (upper - lower) / lower > EPS) {
double length = (lower + upper) / 2.;
if (length == preLength) {
break;
}
preLength = length;
long long count = 0;
for (int i = 0; i < n; ++i) {
count += (long long)floor(l[i] / length);
}
if (count >= k) {
lower = length;
} else {
upper = length;
}
}
cout << fixed << setprecision(20) << lower << endl;
return 0;
}
data9824