Submission #416431

#TimeUsernameProblemLanguageResultExecution timeMemory
416431blueMagic Tree (CEOI19_magictree)C++17
3 / 100
128 ms3112 KiB
#include <iostream> using namespace std; /* Let us assume that every node contains a fruit, and that if this fruit isn't in the input, it's w value is 0, and d value is 1. Let t[v[j]] = d[j] All optimal cuts are of the following type: - Cut the node u at time t[u]. The time at which we cut u must be <= the time at which we cut any ancestor of u. The time at which we cut u must be >= the time at which we cut any descendant of u. dp[u] =def= the maximum amount of juice we can collect from subtree of u, if u is cut at t[u]; */ int main() { int n, m, k; cin >> n >> m >> k; int p[n+1]; for(int i = 2; i <= n; i++) cin >> p[i]; long long res = 0; for(int f = 1; f <= m; f++) { int v, d, w; cin >> v >> d >> w; res += w; } cout << res << '\n'; }
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...