Submission #153364

#TimeUsernameProblemLanguageResultExecution timeMemory
153364arnold518Friend (IOI14_friend)C++14
100 / 100
39 ms3448 KiB
#include "friend.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 1e5; pii dp[MAXN+10]; int findSample(int N, int *C, int *H, int *P) { int i, j; for(i=0; i<N; i++) dp[i]={C[i], 0}; for(i=N-1; i>=1; i--) { if(P[i]==0) dp[H[i]]={dp[H[i]].first+dp[i].second, max(dp[i].first+dp[H[i]].second, dp[i].second+dp[H[i]].second)}; else if(P[i]==1) dp[H[i]]={max({dp[H[i]].first+dp[i].second, dp[i].first+dp[H[i]].second, dp[i].first+dp[H[i]].first}), dp[i].second+dp[H[i]].second}; else dp[H[i]]={max(dp[H[i]].first+dp[i].second, dp[i].first+dp[H[i]].second), dp[i].second+dp[H[i]].second}; } return max(dp[0].first, dp[0].second); }

Compilation message (stderr)

friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:15:12: warning: unused variable 'j' [-Wunused-variable]
     int i, j;
            ^
#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...