結果
| 問題 |
No.67 よくある棒を切る問題 (1)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2014-11-16 23:33:26 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 401 bytes |
| コンパイル時間 | 444 ms |
| コンパイル使用メモリ | 43,264 KB |
| 実行使用メモリ | 11,556 KB |
| 最終ジャッジ日時 | 2025-03-03 10:02:20 |
| 合計ジャッジ時間 | 9,336 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 16 TLE * 1 -- * 13 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:6:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
6 | scanf("%d",&n);
| ~~~~~^~~~~~~~~
main.cpp:9:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
9 | scanf("%lf",&v[i]);
| ~~~~~^~~~~~~~~~~~~
main.cpp:11:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
11 | scanf("%lld",&k);
| ~~~~~^~~~~~~~~~~
ソースコード
#include <vector>
#include <cstdio>
int main(){
int n;
long long k;
scanf("%d",&n);
std::vector<double>v(n);
for(int i=0;i<n;i++){
scanf("%lf",&v[i]);
}
scanf("%lld",&k);
double mi=0,ma=1e9;
for(;mi+1e-10<ma;){
long long _n=0;
double h=(mi+ma)/2;
for(int i=0;i<n;i++){
_n+=v[i]/h;
}
if(_n>=k){
mi=h;
}else{
ma=h;
}
}
printf("%.10f\n",mi);
}