QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#864406#9854. Find the Maximumxyppyx#WA 42ms12696kbC++141.2kb2025-01-20 16:10:122025-01-20 16:10:13

Judging History

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

  • [2025-01-20 16:10:13]
  • 评测
  • 测评结果:WA
  • 用时:42ms
  • 内存:12696kb
  • [2025-01-20 16:10:12]
  • 提交

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("%llf", &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;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 7112kb

input:

2
3 2
1 2

output:

1.562500

result:

ok Accept!

Test #2:

score: 0
Accepted
time: 39ms
memory: 12696kb

input:

100000
92267 92164 51606 26141 24879 -67311 -25229 -65514 77800 -9213 -65704 -59430 21111 94890 39508 -13162 58661 34181 -86666 -29450 1588 -18722 -75565 15211 28028 -39385 -97517 -85584 -9097 13770 31381 -21566 37697 19483 74839 -31752 -10681 -93336 -69242 46591 -76345 -15194 69484 34351 -121 91430...

output:

2372729047.111111

result:

ok Accept!

Test #3:

score: 0
Accepted
time: 42ms
memory: 12524kb

input:

100000
20036 58982 -54696 2627 -93016 66529 34860 -1438 49628 -5386 70370 25036 -67285 -70258 27348 59316 -67699 18718 36124 -37387 80279 1315 -18946 84067 -12213 -72069 79001 52586 -19913 2496 19794 54569 -96918 -31049 554 -33785 44773 -21375 -4087 -87453 5134 -84574 -53715 47515 20914 4808 -50228 ...

output:

1344835584.000000

result:

ok Accept!

Test #4:

score: 0
Accepted
time: 38ms
memory: 12496kb

input:

100000
-63335 57151 81047 -66724 -99858 60401 62337 -8832 59071 -33606 -78529 97304 -22976 -42931 -75137 -75522 59687 -94876 -86564 -91692 -96959 -89699 -64180 -47471 -33475 -59840 20255 -58826 73842 99259 6635 7286 -96421 73755 -74049 -2383 59482 51168 89847 79514 -68221 -58318 4767 -54946 5226 219...

output:

1926127285.444444

result:

ok Accept!

Test #5:

score: 0
Accepted
time: 1ms
memory: 7756kb

input:

2
-100000 -11453
1 2

output:

776360700.562500

result:

ok Accept!

Test #6:

score: 0
Accepted
time: 1ms
memory: 7472kb

input:

2
82384 -97348
1 2

output:

13995081.000000

result:

ok Accept!

Test #7:

score: 0
Accepted
time: 0ms
memory: 6860kb

input:

2
1 93748
1 2

output:

549304687.562500

result:

ok Accept!

Test #8:

score: 0
Accepted
time: 1ms
memory: 6476kb

input:

3
83355 93748 -94895
1 2
1 3

output:

1960342038.062500

result:

ok Accept!

Test #9:

score: -100
Wrong Answer
time: 0ms
memory: 6596kb

input:

3
-83355 94895 93748
1 3
1 2

output:

8323225.000000

result:

wrong answer Wrong Answer!