Submission #1178075

#TimeUsernameProblemLanguageResultExecution timeMemory
1178075KasymKRoad Closures (APIO21_roads)C++17
7 / 100
23 ms4544 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 pli pair<ll, int>
#define pll pair<ll, ll>
#define tr(i, c) for(auto i = c.begin(); i != c.end(); ++i)
#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 = 2e5+5;
ll dp[N];

vector<ll> minimum_closure_costs(int n, vector<int> u, vector<int> v, vector<int> w){
    vector<ll> ret;
    ll sm=accumulate(all(w), 0ll);
    dp[0]=w[0], dp[1]=max(w[1], w[0]);
    for(int i = 2; i < n; ++i)
        dp[i]=max(dp[i-1], dp[i-2]+w[i]);
    ret.pb(sm), ret.pb(sm-dp[n-2]);
    for(int i = 0; i < n-2; ++i)
        ret.pb(0);
    return ret;
}

// int main(){
//     int n;
//     scanf("%d", &n);
//     vector<int> u, v, w;
//     for(int i = 1; i < n; ++i){
//         int a, b, c;
//         scanf("%d%d%d", &a, &b, &c);
//         u.pb(a), v.pb(b), w.pb(c);
//     }
//     vector<ll> A=minimum_closure_costs(n, u, v, w);
//     tr(it, A)
//     printf("%lld ", *it);
//     return 0;
// }
#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...