# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
388014 | 2021-04-09T18:12:19 Z | b00n0rp | Biochips (IZhO12_biochips) | C++17 | 295 ms | 399256 KB |
/* not my code. checking to submit whether the site is even working */ #include<bits/stdc++.h> using namespace std; int val[200001], m, t; vector<int> g[200001]; int dp[200001][501], par[200001]; void dfs(int c) { par[c] = t; for(int e : g[c]) dfs(e); for(int i=1;i<=m;i++) dp[t+1][i] = max(dp[t][i],dp[par[c]][i-1]+val[c]); t++; } int main() { int n, r; scanf("%d%d",&n,&m); for(int i=1;i<=n;i++) { int p; scanf("%d%d",&p,val+i); if(!p) r = i; else g[p].push_back(i); } for(int i=1;i<=m;i++) dp[0][i] = -1e9; dfs(r); printf("%d\n",dp[n][m]); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 4940 KB | Output is correct |
2 | Correct | 3 ms | 4940 KB | Output is correct |
3 | Correct | 3 ms | 5168 KB | Output is correct |
4 | Correct | 14 ms | 22692 KB | Output is correct |
5 | Correct | 14 ms | 24812 KB | Output is correct |
6 | Correct | 14 ms | 24880 KB | Output is correct |
7 | Correct | 219 ms | 297848 KB | Output is correct |
8 | Correct | 210 ms | 297964 KB | Output is correct |
9 | Correct | 248 ms | 361792 KB | Output is correct |
10 | Correct | 295 ms | 399256 KB | Output is correct |