結果

問題 No.2009 Drunkers' Contest
ユーザー okkuukenkenokkuukenken
提出日時 2022-07-15 21:51:03
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 960 bytes
コンパイル時間 1,851 ms
コンパイル使用メモリ 128,344 KB
実行使用メモリ 13,344 KB
最終ジャッジ日時 2023-09-10 01:25:09
合計ジャッジ時間 9,198 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,384 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 1 ms
4,380 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 3 ms
4,380 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 151 ms
6,632 KB
testcase_26 WA -
testcase_27 AC 150 ms
6,628 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 151 ms
6,612 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 AC 168 ms
12,804 KB
testcase_45 AC 163 ms
6,600 KB
testcase_46 AC 115 ms
12,340 KB
testcase_47 AC 91 ms
13,344 KB
testcase_48 AC 90 ms
12,796 KB
testcase_49 AC 90 ms
13,136 KB
testcase_50 AC 91 ms
12,592 KB
testcase_51 AC 92 ms
12,652 KB
testcase_52 AC 89 ms
9,564 KB
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 AC 107 ms
9,356 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>ab[i]){
			if(vec.back().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)
		if(x.a>x.b)
			ans+=2*sqrt(x.a*x.b);
		else
			ans+=x.a+x.b;
	cout<<fixed<<setprecision(20)<<ans<<endl;
}
0