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<bits/stdc++.h>
using namespace std;
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
#include "friend.h"
// Find out best sample
//0 - i am you friend
//1 - my friends are your friends
//2 - we are your friends
int findSample(int n,int cost[],int par[],int t[]){
int ans = 0;
for (int u = n - 1; u; --u) {
if (cost[u] <= 0)
continue;
if (t[u] == 0) {
cost[par[u]] -= cost[u];
//???
cost[par[u]] = max(cost[par[u]], 0);
ans += cost[u];
}
else if (t[u] == 1) {
cost[par[u]] += cost[u];
}
else if (t[u] == 2) {
cost[par[u]] = max(cost[par[u]], cost[u]);
}
}
ans += max(0, cost[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... |