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"
#include <algorithm>
using namespace std;
int res[100006][2];
int findSample(int n, int confidence[], int host[], int protocol[]) {
for (int i = 0; i < n; i++) res[i][1] = confidence[i], res[i][0] = 0;
for (int i = n - 1; i > 0; i--) {
if (protocol[i] == 0) {
res[host[i]][1] = res[i][0] + res[host[i]][1];
res[host[i]][0] = max(res[i][0], res[i][1]) + res[host[i]][0];
} else if (protocol[i] == 1) {
res[host[i]][1] = max(res[i][1], res[i][0]) + max(res[host[i]][1], res[host[i]][0]);
res[host[i]][0] = res[i][0] + res[host[i]][0];
} else {
res[host[i]][1] = max(res[host[i]][1] + res[i][0], res[host[i]][0] + res[i][1]);
res[host[i]][0] = res[host[i]][0] + res[i][0];
}
}
return max(res[0][0], res[0][1]);
}
# | 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... |