Submission #1111827

#TimeUsernameProblemLanguageResultExecution timeMemory
1111827ezzzaySjekira (COCI20_sjekira)C++14
110 / 110
59 ms2896 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define ff first #define ss second #define pb push_back const int N=3e5+5; int c[N]; int ans=0; signed main(){ int n; cin>>n; int mx=0; for(int i=1;i<=n;i++){ cin>>c[i]; ans+=c[i]; mx=max(mx,c[i]); } ans-=mx; for(int i=1;i<n;i++){ int a,b; cin>>a>>b; ans+=max(c[a],c[b]); } cout<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...