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 rep(i,a,b) for (int i = (a); i <= (b); i++)
#define repa(i,a,b) for (int i = (a); i >= (b); i--)
#define lli long long int
#define debugsl(a) cout << #a << " = " << a << ", "
#define debug(a) cout << #a << " = " << a << endl
#define MAX 100000
#define des first
#define peso second
vector< pair<lli,lli> > hijos[MAX+2];
lli dp[MAX+2][2];
std::vector <long long> minimum_closure_costs(int N, std::vector<int> U, std::vector<int> V, std::vector<int> W) {
vector<long long> res (N, 0);
rep(i,0,N-2) {
hijos[ U[i] ].push_back({V[i], W[i]});
hijos[ V[i] ].push_back({U[i], W[i]});
}
rep(i,1,N-1) {
for (auto h : hijos[i]) if (h.des == i-1) {
dp[i][1] = dp[i-1][0];
dp[i][0] = min(dp[i-1][0], dp[i-1][1]);
dp[i][0] += h.peso;
res[0] += h.peso;
}
}
res[1] = min(dp[N-1][0], dp[N-1][1]);
return res;
}
# | 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... |