제출 #749925

#제출 시각아이디문제언어결과실행 시간메모리
749925Abrar_Al_Samit친구 (IOI14_friend)C++17
19 / 100
1 ms468 KiB
#include "friend.h" #include <bits/stdc++.h> using namespace std; const int nax = 1000; vector<int>g[nax]; int a[nax]; long long dp[nax][2]; long long dfs(int v, int perm) { long long &ret = dp[v][perm]; if(ret!=-1) return ret; ret = 0; for(int u : g[v]) { ret += dfs(u, 1); } if(perm) { long long an = a[v]; for(int u : g[v]) { an += dfs(u, 0); } ret = max(ret, an); } return ret; } int findSample(int n,int confidence[],int host[],int protocol[]){ for(int i=0; i<n; ++i) { a[i] = confidence[i]; } for(int i=1; i<n; ++i) { g[host[i]].push_back(i); } memset(dp, -1, sizeof dp); return dfs(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...