제출 #131547

#제출 시각아이디문제언어결과실행 시간메모리
131547Mahdi_Jfri친구 (IOI14_friend)C++14
100 / 100
39 ms3192 KiB
#include "friend.h" #include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back const int maxn = 1e5 + 20; int dp[maxn][2]; int findSample(int n,int A[],int host[],int pt[]) { for(int i = 0; i < n; i++) dp[i][1] = A[i]; for(int u = n - 1; u > 0; u--) { int v = host[u]; int tmp[2] = {0 , 0}; for(int x = 0; x < 2; x++) for(int y = 0; y < 2; y++) { if(x && y && pt[u] != 1) continue; if(pt[u]) tmp[x | y] = max(tmp[x | y] , dp[v][x] + dp[u][y]); else tmp[x] = max(tmp[x] , dp[v][x] + dp[u][y]); } dp[v][0] = tmp[0] , dp[v][1] = tmp[1]; } return max(dp[0][1] , dp[0][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...