제출 #152017

#제출 시각아이디문제언어결과실행 시간메모리
152017ignifi친구 (IOI14_friend)C++14
27 / 100
5 ms2808 KiB
#include "friend.h" #include <bits/stdc++.h> using namespace std; typedef pair<int, int> pii; constexpr int MAXN = 100000; vector<pii> adj[MAXN + 2]; int *conf; pii recur(int u) { int a = 0, b = 0, c = 0, d = 0; for(pii vt : adj[u]) { int v = vt.first, t = vt.second; pii res = recur(v); int va = res.first, vb = res.second; if(t == 0) { a += max(va, vb); } else { c = max(c, b + vb); if(t == 1) d = max(d, vb - va); } b += va; } b += conf[u] + d; return make_pair(a, max(b, c)); } // Find out best sample int findSample(int n,int confidence[],int host[],int protocol[]){ int cum = 0, i = 1; while(i < n && host[i] == 0 && protocol[i] == 1) cum += confidence[i++]; while(i < n) { adj[host[i]].push_back(make_pair(i, protocol[i])); i++; } conf = confidence; pii res = recur(0); return cum + max(res.first, res.second); }
#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...