#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 |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
58 ms |
1676 KB |
Output is correct |
2 |
Correct |
52 ms |
1604 KB |
Output is correct |
3 |
Correct |
128 ms |
3112 KB |
Output is correct |
4 |
Correct |
109 ms |
2756 KB |
Output is correct |
5 |
Correct |
125 ms |
3016 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
113 ms |
2688 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
436 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |