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 "friend.h"
int findSample(int n, int c[], int h[], int p[]) {
int ans = 0;
for (int i = n - 1; i > 0; i--) {
if (p[i] == 0) { c[h[i]] -= c[i]; ans += c[i]; }
if (p[i] == 1) c[h[i]] += c[i];
if (p[i] == 2 && c[i] > c[h[i]]) c[h[i]] = c[i];
}
return ans + (c[0] > 0 ? c[0] : 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |