# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1116577 | 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) {
long long 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 <long long> 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;
}