QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#864405#9854. Find the Maximumxyppyx#WA 0ms6400kbC++141.2kb2025-01-20 16:09:312025-01-20 16:09:32

Judging History

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

  • [2025-01-20 16:09:32]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:6400kb
  • [2025-01-20 16:09:31]
  • 提交

answer

#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

typedef long double ll;
const int N = 1e5 + 5;
vector<ll> tree[N];
int n;
ll w[N];

int main()
{
    scanf("%d", &n);
    for(int i = 1; i <= n; i++)scanf("%lld", &w[i]);
    int x, y;
    for(int i = 1; i < n; i++)
    {
        scanf("%d %d", &x, &y);
        tree[x].push_back(w[y]);
        tree[y].push_back(w[x]);
    }
    for(int i = 1; i <= n; i++)sort(tree[i].begin(), tree[i].end());

    double ans = -0x7f7f7f7f;
    for(int i = 1; i <= n; i++)
    {
        double tmp1 = 0, tmp2 = 0;
        tmp1 = (1.0 * w[i] + tree[i][tree[i].size() - 1]) / 2.0;
        if(tree[i].size() > 3)
            tmp2 = (1.0 * w[i] + tree[i][tree[i].size() - 1] + tree[i][tree[i].size() - 2]) / 3.0;
        ans = max(ans, tmp1);
        ans = max(ans, tmp2);
    }
    for(int i = 1; i <= n; i++)
    {
        double tmp1 = 0, tmp2 = 0x7f7f7f7f;
        tmp1 = (1.0 * w[i] + tree[i][0]) / 2.0;
        if(tree[i].size() > 3)
            tmp2 = (1.0 * w[i] + tree[i][0] + tree[i][1]) / 3.0;
        ans = max(ans, -tmp1);
        ans = max(ans, -tmp2);
    }
    ans = ans * ans / 4.0;
    printf("%.6lf\n", ans);
    //while(1);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
3 2
1 2

output:

0.000000

result:

wrong answer Wrong Answer!