#include <algorithm>
using namespace std;
using ll=long long;
const int maxn = int(1e5) + 10;
int findSample(int n, int confidence[], int host[], int protocol[]) {
static ll weight[maxn];
for (int i=0; i<n; ++i) weight[i] = confidence[i];
ll base = 0;
for (int i=n-1; 0<i; --i) {
int h = host[i];
if (protocol[i] == 0) {
base += weight[i];
weight[h] -= weight[i];
weight[h] = max(weight[h], 0ll);
} else if (protocol[i] == 1) {
weight[h] += weight[i];
} else {
weight[h] = max(weight[h], weight[i]);
}
}
return base + weight[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... |