結果
| 問題 | No.67 よくある棒を切る問題 (1) |
| コンテスト | |
| ユーザー |
Lay_ec
|
| 提出日時 | 2014-11-17 00:04:45 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 728 bytes |
| 記録 | |
| コンパイル時間 | 474 ms |
| コンパイル使用メモリ | 101,088 KB |
| 実行使用メモリ | 9,856 KB |
| 最終ジャッジ日時 | 2026-07-06 15:20:24 |
| 合計ジャッジ時間 | 7,775 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 2 TLE * 1 -- * 27 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:47:23: warning: 'm' may be used uninitialized [-Wmaybe-uninitialized]
47 | printf("%.16f\n",m);
| ~~~~~~^~~~~~~~~~~~~
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;
}
Lay_ec