結果

問題 No.2009 Drunkers' Contest
ユーザー kabipoyokabipoyo
提出日時 2022-07-16 22:09:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 160 ms / 2,000 ms
コード長 1,464 bytes
コンパイル時間 5,422 ms
コンパイル使用メモリ 264,308 KB
実行使用メモリ 9,524 KB
最終ジャッジ日時 2023-09-11 08:00:49
合計ジャッジ時間 14,764 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 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,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 3 ms
4,376 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 3 ms
4,380 KB
testcase_17 AC 4 ms
4,376 KB
testcase_18 AC 4 ms
4,376 KB
testcase_19 AC 4 ms
4,376 KB
testcase_20 AC 4 ms
4,376 KB
testcase_21 AC 4 ms
4,376 KB
testcase_22 AC 4 ms
4,380 KB
testcase_23 AC 5 ms
4,380 KB
testcase_24 AC 150 ms
6,344 KB
testcase_25 AC 151 ms
6,224 KB
testcase_26 AC 151 ms
6,332 KB
testcase_27 AC 151 ms
6,268 KB
testcase_28 AC 151 ms
6,196 KB
testcase_29 AC 150 ms
6,492 KB
testcase_30 AC 150 ms
6,332 KB
testcase_31 AC 151 ms
6,200 KB
testcase_32 AC 152 ms
6,236 KB
testcase_33 AC 151 ms
6,220 KB
testcase_34 AC 135 ms
6,148 KB
testcase_35 AC 135 ms
6,196 KB
testcase_36 AC 135 ms
6,348 KB
testcase_37 AC 134 ms
6,332 KB
testcase_38 AC 135 ms
6,268 KB
testcase_39 AC 136 ms
6,272 KB
testcase_40 AC 134 ms
6,240 KB
testcase_41 AC 134 ms
6,192 KB
testcase_42 AC 135 ms
6,272 KB
testcase_43 AC 134 ms
6,236 KB
testcase_44 AC 160 ms
6,200 KB
testcase_45 AC 160 ms
6,276 KB
testcase_46 AC 109 ms
6,232 KB
testcase_47 AC 89 ms
9,516 KB
testcase_48 AC 89 ms
9,524 KB
testcase_49 AC 89 ms
9,316 KB
testcase_50 AC 89 ms
9,140 KB
testcase_51 AC 88 ms
9,136 KB
testcase_52 AC 88 ms
8,352 KB
testcase_53 AC 110 ms
8,100 KB
testcase_54 AC 107 ms
7,304 KB
testcase_55 AC 105 ms
6,660 KB
testcase_56 AC 104 ms
6,516 KB
testcase_57 AC 106 ms
8,084 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef int64_t lint;
#define rep(i, n) for(int i=0; i<n; i++)
#define repx(i, l, n) for(int i=l; i<n; i++)
#define all(v) v.begin(), v.end()
#define show(x) cout << #x << ": " << x << endl;
#define list(x) cout << #x << ": " << x << "  ";
#define pb push_back
using vi = vector<lint>;
using vvi = vector<vector<lint>>;
template<class T> inline void vin(vector<T>& v) { rep(i, v.size()) cin >> v.at(i); }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline void drop(T x) { cout << x << endl; exit(0); }
template<class T> void vout(vector<T> v) { rep(i, v.size()) { cout << v.at(i) << ' '; } cout << endl; }
constexpr lint LINF = LLONG_MAX/2;
using pint = pair<lint, lint>;
using vp = vector<pint>;

int main() {
	lint N;
	cin >> N;
	vi v(N), w(N);
	vin(v);
	vin(w);

	long double a=0, b=0, c=0, x=0, y=0, z;
	stack<pint> s;
	rep(i, N) {
		x = v[N-1-i], y = w[N-1-i];
		while (!s.empty()) {
			tie(b, c) = s.top();
			if (x*c >= b*y) {
				s.pop();
				x += b, y += c;
			} else {
				break;
			}
		}
		s.push({x, y});
	}
	while (!s.empty()) {
		tie(x, y) = s.top();
		s.pop();
		if (x < y) a += x+y;
		else {
			z = sqrt((double)x/y);
			a += x/z+y*z;
		}
	}
	cout << fixed << setprecision(10) << a << endl;
}
0