# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1060085 | aymanrs | Nestabilnost (COI23_nestabilnost) | C++17 | 455 ms | 524288 KiB |
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;
vector<int> cost;int N;
struct node {
vector<long long> dp;
long long free;
vector<node*> l;
int a;
};
void dfs(node* n, node* p){
for(node* c : n->l) if(c!=p) dfs(c,n);
n->dp.resize(N+1);
n->free = LONG_LONG_MAX;
for(int k = n->a+1;k <= N;k++){
n->dp[k] = cost[k];
for(node* c : n->l){
if(c==p) continue;
if(!c->a){
if(k == n->a+1) n->dp[k] += min(c->dp[k]-cost[k], c->free);
else n->dp[k] += c->free;
} else if(c->a == n->a+1){
if(k>c->a) n->dp[k] += min(c->dp[k]-cost[k], c->free);
else n->dp[k] += c->free;
} else n->dp[k] += c->free;
}
n->free = min(n->free, n->dp[k]);
}
}
void solve(){
int n;cin >> n;
# | 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... |