QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#864405 | #9854. Find the Maximum | xyppyx# | WA | 0ms | 6400kb | C++14 | 1.2kb | 2025-01-20 16:09:31 | 2025-01-20 16:09:32 |
Judging History
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;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 6400kb
input:
2 3 2 1 2
output:
0.000000
result:
wrong answer Wrong Answer!