# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
133692 | antimirage | Friend (IOI14_friend) | C++14 | 0 ms | 0 KiB |
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;
int findSample(int n,int c[],int p[],int t[]){
int ans = 0;
for (int i = n - 1'; i >= 0; i--) {
if (t[i] == 0) {
c[p[i]] = max(0, c[p[i]] - c[i]);
ans += c[i];
} else if (t[i] == 1) {
c[p[i]] += c[i];
} else {
c[p[i]] = max( c[p[i]], c[i] );
}
}
return ans + c[0];
}