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;
const int MX=100010;
int findSample(int n, int A[], int F[], int Prot[]){
int X[MX], Y[MX]; // picked / not-picked
for(int i=0; i<n; i++) X[i]=A[i], Y[i]=0;
for(int i=n-1; i>0; i--){
if(Prot[i]==0){
X[F[i]]=X[F[i]]+Y[i];
Y[F[i]]=max(Y[F[i]]+X[i], Y[F[i]]+Y[i]);
}
else if(Prot[i]==1){
X[F[i]]=max({X[F[i]]+Y[i], X[F[i]]+X[i], Y[F[i]]+X[i]});
Y[F[i]]=Y[F[i]]+Y[i];
}
else{
X[F[i]]=max(X[F[i]]+Y[i], Y[F[i]]+X[i]);
Y[F[i]]=Y[F[i]]+Y[i];
}
}
return max(X[0],Y[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... |