Submission #690467

#TimeUsernameProblemLanguageResultExecution timeMemory
690467Dan4LifeRoad Closures (APIO21_roads)C++17
12 / 100
50 ms7220 KiB
#include "roads.h" #include <bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back #define sz(a) (int)a.size() #define all(a) a.begin(),a.end() using ll = long long; const int maxn = (int)2e5+10; const int INF = (int)1e9; vector<ll> minimum_closure_costs(int N, vector<int> U, vector<int> V, vector<int> W) { vector<ll> ans(N,0ll); ans[0] = accumulate(all(W),0ll); if(accumulate(all(U),0ll)==0ll){ sort(all(W)); reverse(all(W)); int i = 0; ll tot = accumulate(all(W),0ll); for(auto &u : ans) u=tot,tot-=W[i++]; return ans; } ll dp[N-1][2]; dp[0][0] = dp[0][1] = 0; for(int i = 1; i < N; i++){ dp[i][0] = min(dp[i-1][1],dp[i-1][0])+W[i-1]; dp[i][1] = dp[i-1][0]; } ans[1] = min(dp[N-1][0],dp[N-1][1]); 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...