結果
問題 |
No.67 よくある棒を切る問題 (1)
|
ユーザー |
![]() |
提出日時 | 2014-11-17 00:04:45 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 728 bytes |
コンパイル時間 | 764 ms |
コンパイル使用メモリ | 81,484 KB |
実行使用メモリ | 8,480 KB |
最終ジャッジ日時 | 2025-03-03 10:05:44 |
合計ジャッジ時間 | 7,796 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 2 TLE * 1 -- * 27 |
コンパイルメッセージ
In file included from /usr/include/stdio.h:980, from /usr/include/c++/13/cstdio:42, from /usr/include/c++/13/ext/string_conversions.h:45, from /usr/include/c++/13/bits/basic_string.h:4109, from /usr/include/c++/13/string:54, from /usr/include/c++/13/bits/locale_classes.h:40, from /usr/include/c++/13/bits/ios_base.h:41, from /usr/include/c++/13/ios:44, from /usr/include/c++/13/ostream:40, from /usr/include/c++/13/iostream:41, from main.cpp:1: In function ‘int printf(const char*, ...)’, inlined from ‘int main()’ at main.cpp:47:9: /usr/include/x86_64-linux-gnu/bits/stdio2.h:86:23: warning: ‘m’ may be used uninitialized [-Wmaybe-uninitialized] 86 | return __printf_chk (__USE_FORTIFY_LEVEL - 1, __fmt, __va_arg_pack ()); | ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ main.cpp: In function ‘int main()’: main.cpp:31:37: note: ‘m’ was declared here 31 | double l=0,r=L[n-1],m; | ^
ソースコード
#include <iostream> #include <string> #include <vector> #include <cmath> #include <algorithm> #include <cstdlib> #include <ctime> #include <cstdio> #include <functional> #include <set> #include <sstream> #include <cctype> using namespace std; int main(){ long n,k; cin>>n; vector<long> L(n); for(long i=0;i<n;i++) cin>>L[i]; cin>>k; sort(L.begin(),L.end()); if(n>=k) cout<<L[n-k]; else{ double l=0,r=L[n-1],m; while((r-l)>1e-12){ unsigned long long num=0; m=(l+r)/2.0; for(long i=0;i<n;i++) num+=floor(L[i]/m); // cout<<"m="<<m<<"->"<<num<<endl; if(num<k) r=m; else{ l=m; } } printf("%.16f\n",m); } return 0; }