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 "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;
int 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 = 1; 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 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... |