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"
#define max(a, b) ((a) > (b) ? (a) : (b))
int findSample(int n, int val[], int host[], int typ[]){
int ans = 0;
for(int i = n - 1; i >= 1; --i) {
int &A = val[host[i]], &B = val[i];
if(typ[i] == 0) ans += B, A = max(0, A - B);
if(typ[i] == 1) A += B;
if(typ[i] == 2) A = max(A, B);
}
return ans + val[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... |