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 <iostream>
#include <fstream>
#include "friend.h"
using namespace std;
int const NMAX = 1e5;
int ans[2][1 + NMAX];
int findSample(int n, int confidence[], int host[], int protocol[]) {
for(int i = 0;i < n;i++) {
ans[1][i] = confidence[i];
ans[0][i] = 0;
}
for(int i = n-1;i > 0;i--) {
int temp0, temp1;
if(protocol[i] == 0) {
temp0 = max(ans[0][host[i]] + ans[0][i], ans[0][host[i]] + ans[1][i]);
temp1 = ans[1][host[i]] + ans[0][i];
}else if(protocol[i] == 1) {
temp0 = ans[0][host[i]] + ans[0][i];
temp1 = max(ans[1][host[i]] + ans[1][i], max(ans[1][host[i]] + ans[0][i], ans[0][host[i]] + ans[1][i]));
}else {
temp0 = ans[0][host[i]] + ans[0][i];
temp1 = max(ans[1][host[i]] + ans[0][i], ans[0][host[i]] + ans[1][i]);
}
ans[0][host[i]] = temp0;
ans[1][host[i]] = temp1;
}
return max(ans[0][0], ans[1][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... |