Submission #607482

#TimeUsernameProblemLanguageResultExecution timeMemory
607482MohamedFaresNebiliFriend (IOI14_friend)C++14
100 / 100
22 ms3160 KiB
#include <bits/stdc++.h> /// #pragma GCC optimize ("Ofast") /// #pragma GCC target ("avx2") /// #pragma GCC optimize("unroll-loops") using namespace std; using ll = long long; using ld = long double; #define ff first #define ss second #define pb push_back #define all(x) (x).begin(), (x).end() #define lb lower_bound const int MOD = 998244353; int DP[100001][2]; int findSample(int N, int* confidence, int* host, int* protocol) { for(int l = 0; l < N; l++) DP[l][1] = confidence[l]; for(int l = N - 1; l > 0; l--) { int t = protocol[l]; if(t == 0) { DP[host[l]][0] += DP[l][1]; DP[host[l]][1] += DP[l][0]; } if(t == 1) { DP[host[l]][1] += DP[l][1]; DP[host[l]][0] += DP[l][0]; } if(t == 2) { DP[host[l]][1] = max(DP[host[l]][0] + DP[l][1], DP[host[l]][1] + DP[l][0]); DP[host[l]][0] += DP[l][0]; } DP[host[l]][1] = max(DP[host[l]][1], DP[host[l]][0]); } return max(DP[0][0], DP[0][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...