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>
#include "friend.h"
using namespace std;
const int N = 1e5+10;
int P[N], NP[N];
int findSample(int n, int confidence[], int host[], int protocol[])
{
for (int i = 0; i < n; ++i)
P[i] = confidence[i], NP[i] = 0;
for (int i = n-1; i > 0; --i) {
int &u = P[host[i]];
int &up = NP[host[i]];
int &v = P[i];
int &vp = NP[i];
int nu, nup;
if (protocol[i] == 0) {
nu = u+vp;
nup = up+max(v,vp);
} else if (protocol[i] == 1) {
nu = max(u+v, max(up+v, u+vp));
nup = up+vp;
} else {
nu = max(u+vp, up+v);
nup = up+vp;
}
u = nu, up = nup;
}
return max(P[0], NP[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... |