結果
| 問題 | No.67 よくある棒を切る問題 (1) |
| コンテスト | |
| ユーザー |
kkslucy1
|
| 提出日時 | 2018-04-08 19:58:26 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 66 ms / 5,000 ms |
| コード長 | 545 bytes |
| 記録 | |
| コンパイル時間 | 926 ms |
| コンパイル使用メモリ | 180,216 KB |
| 実行使用メモリ | 9,232 KB |
| 最終ジャッジ日時 | 2026-07-06 17:18:58 |
| 合計ジャッジ時間 | 4,001 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 30 |
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/ostream:42,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/istream:43,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/sstream:42,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/complex:50,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/ccomplex:43,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/x86_64-pc-linux-gnu/bits/stdc++.h:133,
from main.cpp:1:
In member function 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char; _Traits = std::char_traits<char>]',
inlined from 'int main()' at main.cpp:31:28:
/home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/bits/ostream.h:232:25: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized]
232 | { return _M_insert(__f); }
| ~~~~~~~~~^~~~~
main.cpp: In function 'int main()':
main.cpp:16:16: note: 'ans' was declared here
16 | double ans;
| ^~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> l(n);
for (int i = 0;i < n;i++) {
cin >> l[i];
}
long long k;
cin >> k;
double left = 0;
double right = *max_element(l.begin(), l.end());
double ans;
for (int i = 0;i < 100;i++) {
double mid = (left + right) / 2;
long long count = 0;
for (int i = 0;i < n;i++) {
count += (int)(l[i] / mid);
}
if (count >= k) {
ans = mid;
left = mid;
}
else {
right = mid;
}
}
cout <<setprecision(15)<< ans << endl;
return 0;
}
kkslucy1