Submission #404224

#TimeUsernameProblemLanguageResultExecution timeMemory
404224definitelynotmeeFriend (IOI14_friend)C++98
100 / 100
36 ms3156 KiB
#include <bits/stdc++.h> //#include "friend.h" #define mp make_pair #define mt make_tuple #define ff first #define ss second using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; const ll INFL = (1LL<<62)-1; const int INF = (1<<30)-1; const int MAXN = 1001; int findSample(int n, int confidence[], int host[], int protocol[]){ vector<pii> dp(n); // first -> pegar; second -> não pegar for(int i = 0; i < n; i++) dp[i].ff = confidence[i]; for(int i = n-1; i >0; i--){ switch(protocol[i]){ case 0: dp[host[i]] = {dp[host[i]].ff + dp[i].ss, dp[host[i]].ss + max(dp[i].ff, dp[i].ss)}; break; case 1: dp[host[i]] = {max(dp[host[i]].ff + dp[i].ff, max(dp[host[i]].ff + dp[i].ss, dp[host[i]].ss + dp[i].ff)), dp[host[i]].ss + dp[i].ss}; break; case 2: dp[host[i]] = {max(dp[host[i]].ff + dp[i].ss, dp[host[i]].ss + dp[i].ff), dp[host[i]].ss + dp[i].ss}; } } return max(dp[0].ff, dp[0].ss); }
#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...