Submission #825204

#TimeUsernameProblemLanguageResultExecution timeMemory
825204t6twotwoRoad Closures (APIO21_roads)C++17
12 / 100
40 ms4964 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...