Submission #229362

#TimeUsernameProblemLanguageResultExecution timeMemory
229362osaaateiasavtnlFriend (IOI14_friend)C++14
100 / 100
42 ms2680 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...