Submission #1056206

#TimeUsernameProblemLanguageResultExecution timeMemory
1056206KasymKRoad Closures (APIO21_roads)C++17
7 / 100
22 ms6868 KiB
#include "bits/stdc++.h" using namespace std; #define ff first #define ss second #define all(v) v.begin(), v.end() #define ll long long #define pb push_back #define pii pair<int, int> #define wr puts("----------------") template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;} template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;} const int N = 1e5+5; ll dp[N]; vector<ll> minimum_closure_costs(int n, vector<int> u, vector<int> v, vector<int> w){ vector<ll> A; ll sm = accumulate(all(w), 0ll); A.pb(sm); dp[0] = w[0]; dp[1] = max(w[1], w[0]); for(int i = 2; i < n-1; ++i) umax(dp[i], max(dp[i-1], dp[i-2]+w[i])); ll dxdll = sm-dp[n-2]; A.pb(dxdll); for(int i = 2; i < n; ++i) A.pb(0); return A; }
#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...