QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#562608 | #3950. Great GDP | LaVuna47 | WA | 18ms | 10620kb | C++17 | 2.2kb | 2024-09-13 19:18:36 | 2024-09-13 19:18:36 |
Judging History
answer
/** gnu specific **/
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
/** contains everything I need in std **/
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(S) ((int)S.size())
#define FOR(i, n) for(int i = 0; i < n; ++i)
#define RFOR(i, n) for(int i = n-1; i >= 0; --i)
#define output_vec(vec) { FOR(i_, sz(vec)) cout << vec[i_] << ' '; cout << '\n'; }
#define x first
#define y second
#define pb push_back
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<bool> vb;
typedef short si;
typedef unsigned long long ull;
typedef long double LD;
typedef pair<ull, ull> pull;
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
using namespace std;
#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif
vector<vector<int>> G;
vector<ll> a, b;
double f(int v, int pr, ll up, ll low)
{
double res = double(up)/double(low);
for(auto to: G[v])
{
if(to != pr)
{
res = max(res, f(to, v, up+a[to], low+b[to]));
}
}
return res;
}
int solve()
{
int n;
if (!(cin >> n))
return 1;
a = vector<ll>(n);
b = vector<ll>(n);
FOR(i, n) cin >> a[i];
FOR(i, n) cin >> b[i];
G = vector<vector<int>>(n);
FOR(_, n-1)
{
int u, v;
cin >> u >> v;
--u, --v;
G[u].pb(v);
G[v].pb(u);
}
auto res = f(0, -1, a[0], b[0]);
cout << fixed << setprecision(11) << res << '\n';
return 0;
}
int32_t main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int TET = 1e9;
//cin >> TET;
for (int i = 1; i <= TET; i++)
{
if (solve())
{
break;
}
#ifdef ONPC
cout << "__________________________" << endl;
#endif
}
#ifdef ONPC
cerr << endl << "finished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec" << endl;
#endif
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3872kb
input:
3 3 10 40 1 2 10 1 2 1 3
output:
4.33333333333
result:
ok single line: '4.33333333333'
Test #2:
score: -100
Wrong Answer
time: 18ms
memory: 10620kb
input:
100000 69843 277724 833036 355698 363661 722487 963133 263723 451002 99876 48570 7058 364133 115418 386497 894431 908142 743984 523626 784490 767685 923891 368084 980678 318229 453977 221920 116847 871175 228682 867907 707493 253573 586364 448935 545390 607216 558669 473486 63977 699221 396243 42600...
output:
4.16623744979
result:
wrong answer 1st lines differ - expected: '259.685762915', found: '4.16623744979'