Submission #1042744

#TimeUsernameProblemLanguageResultExecution timeMemory
1042744jer033Friend (IOI14_friend)C++17
100 / 100
14 ms3240 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]; int dnuh = do_not_use[h]; int duh = do_use[h]; if (p == 1) { do_not_use[h] = dnuh+do_not_use[i]; do_use[h] = duh+do_use[i]; } else if (p == 2) { do_not_use[h] = dnuh + do_not_use[i]; do_use[h] = max(dnuh + do_use[i], duh + do_not_use[i]); } else { do_not_use[h] = dnuh + do_use[i]; do_use[h] = duh + 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...