# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
613770 | AugustinasJucas | Road Closures (APIO21_roads) | C++14 | 50 ms | 12256 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;
const int dydis = 1e5 + 10;
vector<pair<int, int> > gr[dydis];
int n, m;
vector<long long> minimum_closure_costs(int N, std::vector<int> U,
std::vector<int> V,
std::vector<int> W) {
n = N; m = W.size();
bool line = true, star = true;
vector<int> mas;
for(int i = 0; i < m; i++) {
int a = U[i]; int b = V[i]; int w = W[i];
if(a != b-1) line = false;
gr[a].push_back({b, w});
gr[b].push_back({a, w});
mas.push_back(w);
}
if(line) {
/// Galiu praleisti max 1 is eiles. Kokia min suma?
long long dp[n]; /// dp[i] - turiu visus iki i ir i-aji emiau. Kokia min suma?
dp[0] = mas[0];
dp[1] = mas[1];
for(int i = 2; i < n; i++) {
dp[i] = min(dp[i-1] + mas[i], dp[i-2] + mas[i]);
}
vector<long long> ret(n, 0);
for(auto x : mas) ret[0] += x;
ret[1] = min(dp[n-1], dp[n-2]);
return ret;
}
return vector<long long>(N, 0);
}
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... |