Submission #990376

#TimeUsernameProblemLanguageResultExecution timeMemory
990376jklepecFriend (IOI14_friend)C++11
100 / 100
20 ms3816 KiB
#include <bits/stdc++.h> #include "friend.h" #define FOR(i, a, b) for(int i = a; i < b; ++i) #define REP(i, n) FOR(i, 0, n) #define _ << " " << #define sz(x) ((int) x.size()) using namespace std; typedef long long ll; typedef pair<int, int> point; const int MAXN = 100005; #define take first #define dont second void Max(int &x, int y) {if(y > x) x = y;} int findSample(int n, int c[], int host[], int p[]) { vector<point> sol; REP(i, n) { sol.push_back({c[i], 0}); } for(int i = n - 1; i; --i) { int j = host[i]; if(p[i] == 0) { sol[j].take += sol[i].dont; Max(sol[j].take, sol[i].take + sol[j].dont); sol[j].dont += max(sol[i].take, sol[i].dont); } if(p[i] == 1) { sol[j].take += max(sol[i].take, sol[i].dont); sol[j].dont += sol[i].dont; } if(p[i] == 2) { sol[j].take += sol[i].dont; Max(sol[j].take, sol[i].take + sol[j].dont); sol[j].dont += sol[i].dont; } } return max(sol[0].take, sol[0].dont); }
#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...