# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
543062 | amunduzbaev | Fireworks (APIO16_fireworks) | C++17 | 26 ms | 1144 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;
#define ar array
#define int long long
const int N = 305;
const int inf = 1e18;
vector<ar<int, 2>> edges[N];
int dp[N][N];
void dfs(int u){
for(auto x : edges[u]){
dfs(x[0]);
for(int j=0;j<N;j++){
int pre = dp[u][j]; dp[u][j] = inf;
for(int l=0;l<=j;l++){
dp[u][j] = min(dp[u][j], pre + dp[x[0]][l] + abs(j - l - x[1]));
}
}
}
if(edges[u].empty()){
memset(dp[u], 63, sizeof dp[u]);
dp[u][0] = 0;
}
}
signed main(){
ios::sync_with_stdio(0); cin.tie(0);
# | 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... |