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 <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 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |