結果
問題 |
No.67 よくある棒を切る問題 (1)
|
ユーザー |
![]() |
提出日時 | 2018-06-14 23:09:42 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,051 bytes |
コンパイル時間 | 821 ms |
コンパイル使用メモリ | 68,444 KB |
実行使用メモリ | 8,604 KB |
最終ジャッジ日時 | 2025-03-03 11:15:45 |
合計ジャッジ時間 | 7,868 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 29 WA * 1 |
ソースコード
#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; }