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 <bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn = 1e5 + 5;
int findSample(int n, int confidence[], int host[], int protocol[]){
ll w[maxn], tot = 0;
for(int i = 0; i < n; i++)
w[i] = confidence[i];
for(int i = n - 1; i >= 1; i--) {
int A = host[i], B = i;
if(protocol[i] == 0) {
w[A] -= w[B];
w[A] = max(w[A], 0LL);
tot += w[B];
} else if(protocol[i] == 1) {
w[A] += w[B];
} else {
w[A] = max(w[A], w[B]);
}
}
return tot + w[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... |