Submission #874119

#TimeUsernameProblemLanguageResultExecution timeMemory
874119itslqFriend (IOI14_friend)C++17
8 / 100
1094 ms348 KiB
#include <bits/stdc++.h> using namespace std; vector<int> children[1005]; long long dp(int w[], int id, bool t) { long long s = 0; if (t == 0) { for (int c: children[id]) { s += max(dp(w, c, 1), dp(w, c, 0)); } } else { s += w[id]; for (int c: children[id]) { s += dp(w, c, 0); } } return s; } int findSample(int n, int confidence[], int host[], int protocol[]) { if (protocol[1] == 0) { for (int i = 1; i < n; i++) children[host[i]].push_back(i); return max(dp(confidence, 0, 0), dp(confidence, 0, 1)); } else if (protocol[1] == 2) { int m = -1; for (int i = 0; i < n; i++) m = max(m, confidence[i]); return m; } return -1; }
#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...