結果
| 問題 |
No.67 よくある棒を切る問題 (1)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2014-11-17 00:04:57 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 450 bytes |
| コンパイル時間 | 373 ms |
| コンパイル使用メモリ | 43,008 KB |
| 実行使用メモリ | 8,608 KB |
| 最終ジャッジ日時 | 2025-03-03 10:06:12 |
| 合計ジャッジ時間 | 3,628 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 26 WA * 4 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:7:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
7 | scanf("%d",&n);
| ~~~~~^~~~~~~~~
main.cpp:10:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
10 | scanf("%lf",&v[i]);
| ~~~~~^~~~~~~~~~~~~
main.cpp:13:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
13 | scanf("%lld",&k);
| ~~~~~^~~~~~~~~~~
ソースコード
#include <vector>
#include <cstdio>
int main(){
int n;
long long k;
double mi=0,ma=0;
scanf("%d",&n);
std::vector<double>v(n);
for(int i=0;i<n;i++){
scanf("%lf",&v[i]);
if(ma<v[i])ma=v[i];
}
scanf("%lld",&k);
//for(;mi+1e-9<ma;){
for(int x=0;x<50;x++){
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("%.14f\n",mi);
}