Submission #559868

#TimeUsernameProblemLanguageResultExecution timeMemory
559868NintsiChkhaidzeSjekira (COCI20_sjekira)C++14
110 / 110
35 ms3184 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 = 100005; ll 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...