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;
#define debugsl(x) cout << #x << " = " << x << ", "
#define debug(x) debugsl(x) << "\n"
#define MAX_N 1000002
#define yo 0
#define ellos 1
#define nosotros 2
int s[MAX_N], no[MAX_N];
// Find out best sample
int findSample(int n,int confidence[],int host[],int protocol[]){
int ans = 0;
for(int i = 0; i < n; ++i) s[i] = confidence[i];
for(int i = n - 1; i > 0; --i){
if (protocol[i] == yo){
s[host[i]] += no[i];
no[host[i]] += max(s[i], no[i]);
}
else if (protocol[i] == ellos){
s[host[i]] = max(max(s[host[i]] + no[i], no[host[i]] + s[i]), s[host[i]] + s[i]);
no[host[i]] += no[i];
}
else if (protocol[i] == nosotros){
s[host[i]] = max(s[host[i]] + no[i], no[host[i]] + s[i]);
no[host[i]] += no[i];
}
}
ans = max(s[0], no[0]);
return ans;
}
# | 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... |