結果
| 問題 |
No.2009 Drunkers' Contest
|
| コンテスト | |
| ユーザー |
milanis48663220
|
| 提出日時 | 2022-07-15 22:38:59 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,332 bytes |
| コンパイル時間 | 1,315 ms |
| コンパイル使用メモリ | 120,408 KB |
| 最終ジャッジ日時 | 2025-01-30 08:27:22 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 1 |
| other | AC * 11 WA * 43 |
ソースコード
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>
#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;
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; }
using namespace std;
typedef long long ll;
template<typename T>
vector<vector<T>> vec2d(int n, int m, T v){
return vector<vector<T>>(n, vector<T>(m, v));
}
template<typename T>
vector<vector<vector<T>>> vec3d(int n, int m, int k, T v){
return vector<vector<vector<T>>>(n, vector<vector<T>>(m, vector<T>(k, v)));
}
template<typename T>
void print_vector(vector<T> v, char delimiter=' '){
if(v.empty()) {
cout << endl;
return;
}
for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter;
cout << v.back() << endl;
}
using P = pair<ll, ll>;
using T = tuple<ll, ll, double>;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout << setprecision(10) << fixed;
int n; cin >> n;
vector<ll> a(n), b(n);
for(int i = 0; i < n; i++) cin >> a[i];
for(int i = 0; i < n; i++) cin >> b[i];
auto f = [&](ll a, ll b){
double x = sqrt((double)a/(double)b);
return max(x, 1.0);
};
vector<T> vt;
for(int i = n-1; i >= 0; i--){
ll aa = a[i], bb = b[i], xx = f(a[i], b[i]);
while(true){
if(vt.empty()){
vt.push_back(T(aa, bb, xx));
break;
}
auto [a_next, b_next, x_next] = vt.back();
if(xx < x_next){
vt.push_back(T(aa, bb, xx));
break;
}else{
vt.pop_back();
aa += a_next;
bb += b_next;
xx = f(aa, bb);
}
}
}
double ans = 0.0;
for(auto [a, b, x]: vt){
// cout << a << ' ' << b << ' ' << x << endl;
ans += (double)a/x + (double)b*x;
}
cout << ans << endl;
}
milanis48663220