Submission #284571

#TimeUsernameProblemLanguageResultExecution timeMemory
284571ScarletSFriend (IOI14_friend)C++17
19 / 100
2 ms512 KiB
#include <bits/stdc++.h> #define ll long long #define sz(x) (int)(x).size() using namespace std; vector<int> edges[1000]; int dp[1000][2]; void dfs(int c, int co[]) { dp[c][1]=co[c]; for (int i : edges[c]) { dfs(i,co); dp[c][1]+=dp[i][0]; dp[c][0]+=max(dp[i][0],dp[i][1]); } } int findSample(int n, int confidence[], int host[], int protocol[]) { for (int i=1;i<n;++i) edges[host[i]].push_back(i); dfs(0,confidence); return max(dp[0][0],dp[0][1]); } /**int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin>>n; int c[n]; for (int i=0;i<n;++i) cin>>c[i]; int h[n]; for (int i=1;i<n;++i) cin>>h[i]; int p[n]; for (int i=1;i<n;++i) cin>>p[i]; cout<<findSample(n,c,h,p); return 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...