結果

問題 No.2009 Drunkers' Contest
ユーザー okkuukenkenokkuukenken
提出日時 2022-07-15 21:53:56
言語 C++23(draft)
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 165 ms / 2,000 ms
コード長 954 bytes
コンパイル時間 1,548 ms
コンパイル使用メモリ 128,108 KB
実行使用メモリ 14,184 KB
最終ジャッジ日時 2023-09-10 01:31:38
合計ジャッジ時間 8,469 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,384 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 3 ms
4,384 KB
testcase_17 AC 3 ms
4,376 KB
testcase_18 AC 4 ms
4,380 KB
testcase_19 AC 4 ms
4,380 KB
testcase_20 AC 4 ms
4,380 KB
testcase_21 AC 5 ms
4,376 KB
testcase_22 AC 4 ms
4,376 KB
testcase_23 AC 5 ms
4,380 KB
testcase_24 AC 154 ms
6,736 KB
testcase_25 AC 153 ms
6,580 KB
testcase_26 AC 154 ms
6,632 KB
testcase_27 AC 153 ms
6,628 KB
testcase_28 AC 153 ms
6,728 KB
testcase_29 AC 152 ms
6,760 KB
testcase_30 AC 154 ms
6,684 KB
testcase_31 AC 153 ms
6,724 KB
testcase_32 AC 153 ms
6,684 KB
testcase_33 AC 152 ms
6,712 KB
testcase_34 AC 136 ms
6,724 KB
testcase_35 AC 136 ms
6,728 KB
testcase_36 AC 136 ms
6,708 KB
testcase_37 AC 136 ms
6,716 KB
testcase_38 AC 136 ms
6,616 KB
testcase_39 AC 136 ms
6,584 KB
testcase_40 AC 137 ms
6,688 KB
testcase_41 AC 137 ms
6,716 KB
testcase_42 AC 137 ms
6,720 KB
testcase_43 AC 137 ms
6,600 KB
testcase_44 AC 165 ms
14,184 KB
testcase_45 AC 164 ms
6,712 KB
testcase_46 AC 114 ms
13,552 KB
testcase_47 AC 91 ms
12,936 KB
testcase_48 AC 89 ms
13,964 KB
testcase_49 AC 95 ms
13,448 KB
testcase_50 AC 91 ms
12,916 KB
testcase_51 AC 90 ms
13,732 KB
testcase_52 AC 89 ms
10,052 KB
testcase_53 AC 110 ms
10,056 KB
testcase_54 AC 111 ms
10,200 KB
testcase_55 AC 107 ms
6,776 KB
testcase_56 AC 106 ms
6,848 KB
testcase_57 AC 107 ms
10,052 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:32:33: 警告: narrowing conversion of ‘a[i]’ from ‘int’ to ‘double’ [-Wnarrowing]
   32 |                 str st{ab[i],a[i],b[i]};
      |                              ~~~^
main.cpp:32:38: 警告: narrowing conversion of ‘b[i]’ from ‘int’ to ‘double’ [-Wnarrowing]
   32 |                 str st{ab[i],a[i],b[i]};
      |                                   ~~~^

ソースコード

diff #

#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;
}
0