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;
using ll = long long;
vector<ll> minimum_closure_costs(int N, vector<int> U, vector<int> V, vector<int> W) {
vector<ll> ans(N);
if (U == vector(N - 1, 0)) {
sort(W.begin(), W.end());
for (int i = 0; i < N - 1; i++) {
ans[N - 2 - i] = ans[N - 1 - i] + W[i];
}
return ans;
}
ll dp0 = 0, dp1 = 0;
for (int i = 0; i < N - 1; i++) {
auto t = dp0;
dp0 = min(dp0, dp1) + W[i];
dp1 = t;
}
ans[0] = accumulate(W.begin(), W.end(), 0LL);
ans[1] = min(dp0, dp1);
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... |