Mai intai trebuie sa te autentifici.
Cod sursa(job #2893242)
Utilizator | Data | 25 aprilie 2022 15:39:12 | |
---|---|---|---|
Problema | Asmax | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.57 kb |
#include<bits/stdc++.h>
using namespace std;
ifstream f("asmax.in");
ofstream g("asmax.out");
#define N 16005
vector<int> t[N];
bool o[N];
int i,j,n,m=-16e6,v[N];
void D(int i)
{
int j,k;
for(o[i]=1,k=t[i].size(),j=0;j<k;++j)
if(!o[t[i][j]]) {
D(t[i][j]);
if(v[t[i][j]]>0)
v[i]+=v[t[i][j]];
}
}
int main()
{
for(f>>n,i=1;i<=n;i++)
f>>v[i];
for(;f>>i>>j;t[i].push_back(j),t[j].push_back(i));
for(D(1),i=1;i<=n;++i)
if(v[i]>m)
m=v[i];
return g<<m,0;
}