제출 #922046

#제출 시각아이디문제언어결과실행 시간메모리
922046Macker친구 (IOI14_friend)C++14
100 / 100
21 ms3416 KiB
#include "friend.h"
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()



// Find out best sample
int findSample(int n,int confidence[],int host[],int protocol[]){
	vector<int> c(n), nc(n, 0);

	for (int i = 0; i < n; i++) {
		c[i] = confidence[i];
	}
	

	for (int i = n - 1; i > 0; i--) {
		if(protocol[i] == 0){
			c[host[i]] = nc[i] + c[host[i]];
			nc[host[i]] = max(nc[host[i]] + nc[i], nc[host[i]] + c[i]);
		}
		else if(protocol[i] == 1){
			c[host[i]] = max(nc[host[i]] + c[i], max(c[host[i]] + nc[i], c[host[i]] + c[i]));
			nc[host[i]] = nc[i] + nc[host[i]];
		}
		else {
			c[host[i]] = max(c[host[i]] + nc[i], c[i] + nc[host[i]]);
			nc[host[i]] = nc[i] + nc[host[i]];
		}
	}
	return max(c[0], nc[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...