# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
727106 | iskhakkutbilim | Road Closures (APIO21_roads) | C++14 | 49 ms | 5652 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 "roads.h"
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
vector<long long> minimum_closure_costs(int N, vector<int> U, vector<int> V, vector<int> W) {
vector<long long> ans;
int sub1 = 1, sub2 = 1;
for(int i = 0;i < N-1; i++){
if(U[i] != 0) sub1 = 0;
if(U[i] != i or V[i] != i+1) sub2 = 0;
}
long long sum = 0LL;
for(int i = 0;i < N-1; i++) sum+= W[i];
ans.push_back(sum);
if(sub1){
sort(W.begin(), W.end());
for(int i = N - 2;i >= 0; i--){
sum -= W[i] * 1LL;
ans.push_back(sum);
}
}else if(sub2){
assert(false);
}else{
assert(false);
}
if(ans.size() != N) assert(false);
return ans;
}
//main(){
// int N; cin >> N;
// vector<int> U(N), V(N), W(N);
// for(int i = 0;i < N-1; i++){
// cin >> U[i] >> V[i];
// }
// for(int i = 0;i < N-1; i++) cin >> W[i];
//
// vector<long long> ans = minimum_closure_costs(N, U, V, W);
//
//}
Compilation message (stderr)
# | 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... |