結果
| 問題 |
No.67 よくある棒を切る問題 (1)
|
| コンテスト | |
| ユーザー |
hang_hang_cln
|
| 提出日時 | 2018-06-14 23:09:08 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,048 bytes |
| コンパイル時間 | 641 ms |
| コンパイル使用メモリ | 68,672 KB |
| 実行使用メモリ | 8,608 KB |
| 最終ジャッジ日時 | 2025-03-03 11:15:43 |
| 合計ジャッジ時間 | 7,734 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 30 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;
long long sticks[200005];
long long countCuttedSticks(double cutLength) {
long long count = 0;
for (int stick: sticks) {
count += stick / cutLength;
}
return count;
}
int main(void){
// Your code here!
int N;
cin >> N;
for (int i=0; i < N; i++) {
cin>>sticks[i];
}
long long K;
cin>>K;
double high, low, ans;
long long max = 0;
for (int i=0; i < N; i++) {
if (max < sticks[i])
max = sticks[i];
}
high = (double)max;
low = 0.0;
if (countCuttedSticks(high) == K)
cout << high << endl;
else {
for(int i = 0; i < 100; i++) {
ans = (high + low) / 2.0;
if (countCuttedSticks(ans) >= K)
low = ans;
else
high = ans;
cout<<high<<","<<low<<endl;
}
cout<<fixed;
cout << setprecision(11)<<ans<< endl;
}
return 0;
}
hang_hang_cln