Submission #559867

#TimeUsernameProblemLanguageResultExecution timeMemory
559867NintsiChkhaidzeSjekira (COCI20_sjekira)C++14
0 / 110
20 ms2264 KiB
#include <bits/stdc++.h> #define pb push_back #define ll long long #define s second #define f first #define left (h<<1),l,(l+r)>>1 #define right ((h<<1)|1),((l+r)>>1) + 1,r using namespace std; const int N = 2000003; int a[N],n,ans,mx; signed main (){ ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL); cin>>n; for (int i = 1; i <= n; i++){ cin>>a[i]; ans += a[i]; if (a[i] > mx) mx = a[i]; } ans-=mx; for (int i = 1; i < n; i++){ int x,y; cin>>x>>y; ans+=max(a[x],a[y]); } 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...