제출 #129342

#제출 시각아이디문제언어결과실행 시간메모리
129342antimirage친구 (IOI14_friend)C++14
35 / 100
3 ms504 KiB
#include "friend.h" //#include "grader.cpp" #include <bits/stdc++.h> #define fr first #define sc second #define mk make_pair #define pb push_back #define all(s) s.begin(), s.end() using namespace std; const int N = 1005; vector <int> g[N]; int a[N], dp[N][2]; void dfs (int v, int p = -1) { dp[v][1] = a[v]; for (auto to : g[v]) { if (to == p) continue; dfs(to, v); dp[v][1] += dp[to][0]; dp[v][0] += max(dp[to][0], dp[to][1]); } } int findSample(int n, int val[], int batya[], int type[]) { int ans = 0; if (type[1] == 1) { for (int i = 0; i < n; i++) { ans += val[i]; } } else if (type[1] == 2) { for (int i = 0; i < n; i++) { ans = max(ans, val[i]); } } else { a[0] = val[0]; for (int i = 1; i < n; i++) { assert(batya[i] < i); g[batya[i]].pb(i); g[i].pb(batya[i]); a[i] = val[i]; } dfs(0); ans = max(dp[0][0], dp[0][1]); } return ans; }
#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...