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;
int a,p[100010],q[100010],A[100010],B[100010];
int findSample(int n, int confidence[], int host[], int protocol[]){
for(int i=0; i<n; i++)p[i]=confidence[i];
for(int i=0; i<n-1; i++)A[i]=host[i],B[i]=protocol[i];
for(int i=n-2;i>=0;i--){
int pj=p[A[i]], qj=q[A[i]], pi=p[i+1], qi=q[i+1];
if(B[i]==0){
p[A[i]]=pj+qi;
q[A[i]]=qj+max(pi, qi);
}
else if(B[i]==1){
p[A[i]]=max(pi+pj, max(pi+qj, qi+pj));
q[A[i]]=qi+qj;
}
else{
p[A[i]]=max(pj+qi, pi+qj);
q[A[i]]=qi+qj;
}
}
return max(q[0], p[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... |