Submission #438681

#TimeUsernameProblemLanguageResultExecution timeMemory
438681prvocisloFriend (IOI14_friend)C++17
100 / 100
33 ms3400 KiB
#include "friend.h" #include <bits/stdc++.h> using namespace std; int findSample(int n,int c[],int h[],int t[]){ vector<int> p(n, 0), q(n, 0); for (int i = 0; i < n; i++) p[i] = c[i]; for (int i = n - 1; i > 0; i--) { if (t[i] == 0) // i am your friend { p[h[i]] = p[h[i]] + q[i]; q[h[i]] = max(q[h[i]] + q[i], q[h[i]] + p[i]); } if (t[i] == 1) // my friends are your friends { p[h[i]] = max({p[h[i]] + p[i], q[h[i]] + p[i], p[h[i]] + q[i]}); q[h[i]] = q[h[i]] + q[i]; } if (t[i] == 2) // we are your friends { p[h[i]] = max(p[h[i]] + q[i], q[h[i]] + p[i]); q[h[i]] = q[h[i]] + q[i]; } p[h[i]] = max(p[h[i]], q[h[i]]); } return max(p[0], q[0]); }
#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...