QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#864410 | #9851. Cup of Water | xyppyx# | RE | 0ms | 0kb | C++14 | 1.2kb | 2025-01-20 16:16:25 | 2025-01-20 16:16:25 |
answer
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long double llf;
const int N = 1e5 + 5;
vector<llf> tree[N];
int n;
llf 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());
llf ans = -0x7f7f7f7f;
for(int i = 1; i <= n; i++)
{
llf 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++)
{
llf 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("%.6llf\n", ans);
//while(1);
return 0;
}
詳細信息
Test #1:
score: 0
Runtime Error
input:
2 0.3 1.5