結果
問題 | No.67 よくある棒を切る問題 (1) |
ユーザー |
|
提出日時 | 2020-06-07 13:09:49 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 130 ms / 5,000 ms |
コード長 | 430 bytes |
コンパイル時間 | 2,023 ms |
コンパイル使用メモリ | 193,604 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2025-03-03 11:39:28 |
合計ジャッジ時間 | 6,580 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:9:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | int n; scanf("%d",&n); | ~~~~~^~~~~~~~~ main.cpp:11:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | rep(i,n) scanf("%lf",&l[i]); | ~~~~~^~~~~~~~~~~~~ main.cpp:12:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 12 | lint k; scanf("%lld",&k); | ~~~~~^~~~~~~~~~~
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; using lint=long long; int main(){ int n; scanf("%d",&n); vector<double> l(n); rep(i,n) scanf("%lf",&l[i]); lint k; scanf("%lld",&k); double lo=0,hi=*max_element(l.begin(),l.end()); rep(_,70){ double mi=(lo+hi)/2; lint cnt=0; rep(i,n) cnt+=l[i]/mi; if(cnt>=k) lo=mi; else hi=mi; } printf("%.15f\n",hi); return 0; }