Submission #1030887

#TimeUsernameProblemLanguageResultExecution timeMemory
1030887UnforgettableplSecurity Guard (JOI23_guard)C++17
37 / 100
84 ms18512 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int n,m,q; cin >> n >> m >> q; vector<int> arr(n+1); for(int i=1;i<=n;i++)cin>>arr[i]; vector<vector<int>> adj(n+1); for(int i=1;i<n;i++){ int a,b; cin >> a >> b; adj[a].emplace_back(b); adj[b].emplace_back(a); } int ans = 0; for(int i=1;i<=n;i++){ ans+=arr[i]*(adj[i].size()-1ll); } cout << ans+(*max_element(arr.begin(),arr.end())) << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...