# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1116576 | PagodePaiva | Road Closures (APIO21_roads) | C++17 | 0 ms | 0 KiB |
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>
#include "roads.h"
#include <vector>
using namespace std;
std::vector<long long> minimum_closure_costs(int n, std::vector<int> U, std::vector<int> V, std::vector<int> W) {
int res = 0;
vector <int> v;
for(int i = 0;i < n-1;i++){
v.push_back(W[i]);
}
sort(v.begin(), v.end());
reverse(v.begin(), v.end());
int res = 0;
vector <int> ans;
ans.push_back(0);
for(int k = n-2;k >= 0;k--){
res += v.back();
v.pop_back();
ans.push_back(res);
}
return ans;
}