結果
問題 | No.2009 Drunkers' Contest |
ユーザー |
![]() |
提出日時 | 2022-07-15 21:53:56 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 183 ms / 2,000 ms |
コード長 | 954 bytes |
コンパイル時間 | 1,563 ms |
コンパイル使用メモリ | 128,572 KB |
実行使用メモリ | 12,680 KB |
最終ジャッジ日時 | 2024-06-27 17:38:32 |
合計ジャッジ時間 | 8,721 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 54 |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:32:33: warning: narrowing conversion of 'a[i]' from 'int' to 'double' [-Wnarrowing] 32 | str st{ab[i],a[i],b[i]}; | ~~~^ main.cpp:32:38: warning: narrowing conversion of 'b[i]' from 'int' to 'double' [-Wnarrowing] 32 | str st{ab[i],a[i],b[i]}; | ~~~^
ソースコード
#include<iostream> #include<vector> #include<algorithm> #include<cmath> #include<string> #include<iomanip> #include<numeric> #include<queue> #include<stack> #include<set> #include<map> using namespace std; typedef long long ll; const int mod=1e9+7; int dx[]={1,0,0,-1},dy[]={0,1,-1,0}; struct str{ double tmp,a,b; }; int main(){ static int n,a[200000],b[200000]; cin>>n; for(int i=0;i<n;i++) cin>>a[i]; for(int i=0;i<n;i++) cin>>b[i]; static double ab[200000]; for(int i=0;i<n;i++) ab[i]=sqrt((double)a[i]/b[i])-1; vector<str>vec; vec.push_back({0,0,0}); for(int i=0;i<n;i++){ str st{ab[i],a[i],b[i]}; while(vec.size()&&vec.back().tmp>st.tmp){ if(vec.back().tmp==0){ st.tmp=0; break; } st.a+=vec.back().a; st.b+=vec.back().b; st.tmp=sqrt(st.a/st.b)-1; vec.pop_back(); } vec.push_back(st); } double ans=0; for(auto x:vec) ans+=x.a/(1+x.tmp)+x.b*(1+x.tmp); cout<<fixed<<setprecision(20)<<ans<<endl; }