Submission #1042740

#TimeUsernameProblemLanguageResultExecution timeMemory
1042740jer033Friend (IOI14_friend)C++17
58 / 100
13 ms2360 KiB
#include "friend.h" #include <bits/stdc++.h> using namespace std; int findSample(int n,int confidence[],int host[],int protocol[]){ vector<int> do_not_use(n, 0); vector<int> do_use(n, 0); for (int i=0; i<n; i++) do_use[i] = confidence[i]; for (int i=n-1; i>=1; i--) { int h = host[i]; int p = protocol[i]; if (p == 1) { do_not_use[h] = do_not_use[h]+do_not_use[i]; do_use[h] = do_use[h]+do_use[i]; } else if (p == 2) { do_not_use[h] = do_not_use[h] + do_not_use[i]; do_use[h] = max(do_use[h] - do_not_use[h], do_use[i] - do_not_use[i]) + do_not_use[h]; } else { do_not_use[h] = do_not_use[h] + do_use[i]; do_use[h] = do_use[h] + do_not_use[i]; do_use[h] = max(do_use[h], do_not_use[h]); } } return max(do_not_use[0], do_use[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...