QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#562607#3950. Great GDPLaVuna47WA 0ms3712kbC++172.2kb2024-09-13 19:17:502024-09-13 19:17:50

Judging History

你现在查看的是最新测评结果

  • [2024-09-13 19:17:50]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3712kb
  • [2024-09-13 19:17:50]
  • 提交

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(15) << 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
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3712kb

input:

3
3 10 40
1 2 10
1 2
1 3

output:

4.333333333333333

result:

wrong answer 1st lines differ - expected: '4.33333333333', found: '4.333333333333333'