Submission #482757

#TimeUsernameProblemLanguageResultExecution timeMemory
482757Valaki2Friend (IOI14_friend)C++14
100 / 100
31 ms4928 KiB
#include "friend.h" #include <bits/stdc++.h> using namespace std; const int IAmYourFriend = 0; const int MyFriendsAreYourFriends = 1; const int WeAreYourFriends = 2; int solve(int n, vector<int> values, vector<int> host, vector<int> type) { int to_add = 0; for(int i = n; i >= 1; i--) { if(type[i] == WeAreYourFriends) { values[host[i]] = max(values[host[i]], values[i]); } if(type[i] == MyFriendsAreYourFriends) { values[host[i]] = values[host[i]] + values[i]; } if(type[i] == IAmYourFriend) { to_add += values[i]; values[host[i]] = max(0, values[host[i]] - values[i]); } } return (to_add + values[0]); } int findSample(int n,int confidence[],int host[],int protocol[]){ int _n = n - 1; vector<int> _values(1 + _n, 0); vector<int> _host(1 + _n, 0); vector<int> _type(1 + _n, 0); _values[0] = confidence[0]; for(int i = 1; i <= _n; i++) { _values[i] = confidence[i]; _host[i] = host[i]; _type[i] = protocol[i]; } return solve(_n, _values, _host, _type); }
#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...