This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
// #define int long long
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define nl "\n"
// subtask 1
const int maxn = 100005;
vector<pair<int, int> > adjlist[maxn];
vector<int64_t> minimum_closure_costs(int N, vector<int> U, vector<int> V, vector<int> W){
for (int i=0; i<N-1; i++){
adjlist[U[i]].push_back(make_pair(W[i], V[i])); //weight, node
adjlist[V[i]].push_back(make_pair(W[i], U[i]));
}
for (auto i : adjlist) sort(i.begin(), i.end());
vector<int64_t> ans;
long long cursum = 0;
ans.push_back(cursum);
for (auto i : adjlist[0]){
cursum += i.first;
ans.push_back(cursum);
}
reverse(ans.begin(), ans.end());
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |