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 <bits/stdc++.h>
using namespace std;
vector<int> children[1005];
int dp(int w[], int id, bool t) {
int s = 0;
if (t == 1) {
for (int c: children[id]) {
s += max(dp(w, c, 1), dp(w, c, 0));
}
} else {
s += w[id];
for (int c: children[id]) {
s += dp(w, c, 0);
}
}
return s;
}
int findSample(int n, int confidence[], int host[], int protocol[]) {
if (protocol[1] == 0) {
for (int i = 1; i < n; i++) children[host[i]].push_back(i);
return max(dp(confidence, 0, 0), dp(confidence, 0, 1));
} else if (protocol[1] == 2) {
int m = -1;
for (int i = 0; i < n; i++) m = max(m, confidence[i]);
return m;
}
return -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... |