Submission #1046522

#TimeUsernameProblemLanguageResultExecution timeMemory
1046522SharkyFriend (IOI14_friend)C++17
100 / 100
14 ms2380 KiB
#include "friend.h" #include <bits/stdc++.h> using namespace std; int findSample(int n, int w[], int h[], int typ[]){ int c[n], u[n]; for (int i = 0; i < n; i++) c[i] = w[i], u[i] = 0; for (int i = n - 1; i >= 1; i--) { int x = h[i], y = i; if (typ[i] == 0) { c[x] += u[y]; u[x] = max(c[y] + u[x], u[x] + u[y]); } else if (typ[i] == 1) { c[x] = max({c[x] + c[y], u[x] + c[y], u[y] + c[x]}); u[x] += u[y]; } else { c[x] = max(u[x] + c[y], u[y] + c[x]); u[x] += u[y]; } } return max(c[0], u[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...