#include <bits/stdc++.h>
using namespace std;
#define type(x) __typeof((x).begin())
#define foreach(it, x) for(type(x) it = (x).begin(); it != (x).end(); it++)
typedef long long ll;
typedef pair < int, int > ii;
const int inf = 1e9 + 333;
const ll linf = 1e18 + inf;
#include "friend.h"
const int N = 100000 + 5;
int a[N], b[N];
// Find out best sample
int findSample(int n,int confidence[],int host[],int protocol[]) {
for(int i = 0; i < n; i++) {
a[i] = confidence[i];
}
for(int i = n - 1; i >= 1; i--) {
int j = host[i];
if(protocol[i] == 0) {
int x = a[j] + b[i];
int y = max(a[i], b[i]) + b[j];
a[j] = x;
b[j] = y;
}
else if(protocol[i] == 1) {
int x = max(max(a[j] + a[i], a[j] + b[i]), b[j] + a[i]);
int y = b[j] + b[i];
a[j] = x;
b[j] = y;
}
else {
int x = max(a[j] + b[i], b[j] + a[i]);
int y = b[j] + b[i];
a[j] = x;
b[j] = y;
}
}
return max(a[0], b[0]);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
3676 KB |
Output is correct |
2 |
Correct |
0 ms |
3676 KB |
Output is correct |
3 |
Correct |
0 ms |
3676 KB |
Output is correct |
4 |
Correct |
0 ms |
3676 KB |
Output is correct |
5 |
Correct |
0 ms |
3676 KB |
Output is correct |
6 |
Correct |
0 ms |
3676 KB |
Output is correct |
7 |
Correct |
0 ms |
3676 KB |
Output is correct |
8 |
Correct |
0 ms |
3676 KB |
Output is correct |
9 |
Correct |
0 ms |
3676 KB |
Output is correct |
10 |
Correct |
0 ms |
3676 KB |
Output is correct |
11 |
Correct |
0 ms |
3676 KB |
Output is correct |
12 |
Correct |
0 ms |
3676 KB |
Output is correct |
13 |
Correct |
0 ms |
3676 KB |
Output is correct |
14 |
Correct |
0 ms |
3676 KB |
Output is correct |
15 |
Correct |
0 ms |
3676 KB |
Output is correct |
16 |
Correct |
0 ms |
3676 KB |
Output is correct |
17 |
Correct |
0 ms |
3676 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
3676 KB |
Output is correct |
2 |
Correct |
0 ms |
3676 KB |
Output is correct |
3 |
Correct |
0 ms |
3676 KB |
Output is correct |
4 |
Correct |
0 ms |
3676 KB |
Output is correct |
5 |
Correct |
0 ms |
3676 KB |
Output is correct |
6 |
Correct |
0 ms |
3676 KB |
Output is correct |
7 |
Correct |
0 ms |
3676 KB |
Output is correct |
8 |
Correct |
0 ms |
3676 KB |
Output is correct |
9 |
Correct |
0 ms |
3676 KB |
Output is correct |
10 |
Correct |
0 ms |
3676 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
3676 KB |
Output is correct |
2 |
Correct |
0 ms |
3676 KB |
Output is correct |
3 |
Correct |
0 ms |
3676 KB |
Output is correct |
4 |
Correct |
0 ms |
3676 KB |
Output is correct |
5 |
Correct |
0 ms |
3676 KB |
Output is correct |
6 |
Correct |
0 ms |
3676 KB |
Output is correct |
7 |
Correct |
0 ms |
3676 KB |
Output is correct |
8 |
Correct |
0 ms |
3676 KB |
Output is correct |
9 |
Correct |
0 ms |
3676 KB |
Output is correct |
10 |
Correct |
0 ms |
3676 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
3676 KB |
Output is correct |
2 |
Correct |
0 ms |
3676 KB |
Output is correct |
3 |
Correct |
0 ms |
3676 KB |
Output is correct |
4 |
Correct |
0 ms |
3676 KB |
Output is correct |
5 |
Correct |
0 ms |
3676 KB |
Output is correct |
6 |
Correct |
0 ms |
3676 KB |
Output is correct |
7 |
Correct |
0 ms |
3676 KB |
Output is correct |
8 |
Correct |
0 ms |
3676 KB |
Output is correct |
9 |
Correct |
0 ms |
3676 KB |
Output is correct |
10 |
Correct |
0 ms |
3676 KB |
Output is correct |
11 |
Correct |
0 ms |
3676 KB |
Output is correct |
12 |
Correct |
0 ms |
3676 KB |
Output is correct |
13 |
Correct |
0 ms |
3676 KB |
Output is correct |
14 |
Correct |
0 ms |
3676 KB |
Output is correct |
15 |
Correct |
0 ms |
3676 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
3676 KB |
Output is correct |
2 |
Correct |
0 ms |
3676 KB |
Output is correct |
3 |
Correct |
0 ms |
3676 KB |
Output is correct |
4 |
Correct |
0 ms |
3676 KB |
Output is correct |
5 |
Correct |
0 ms |
3676 KB |
Output is correct |
6 |
Correct |
0 ms |
3676 KB |
Output is correct |
7 |
Correct |
0 ms |
3676 KB |
Output is correct |
8 |
Correct |
0 ms |
3676 KB |
Output is correct |
9 |
Correct |
0 ms |
3676 KB |
Output is correct |
10 |
Correct |
0 ms |
3676 KB |
Output is correct |
11 |
Correct |
0 ms |
3676 KB |
Output is correct |
12 |
Correct |
0 ms |
3676 KB |
Output is correct |
13 |
Correct |
0 ms |
3676 KB |
Output is correct |
14 |
Correct |
0 ms |
3676 KB |
Output is correct |
15 |
Correct |
0 ms |
3676 KB |
Output is correct |
16 |
Correct |
0 ms |
3676 KB |
Output is correct |
17 |
Correct |
0 ms |
3676 KB |
Output is correct |
18 |
Correct |
0 ms |
3676 KB |
Output is correct |
19 |
Correct |
0 ms |
3676 KB |
Output is correct |
20 |
Correct |
0 ms |
3676 KB |
Output is correct |
21 |
Correct |
0 ms |
3676 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
3676 KB |
Output is correct |
2 |
Correct |
0 ms |
3676 KB |
Output is correct |
3 |
Correct |
0 ms |
3676 KB |
Output is correct |
4 |
Correct |
0 ms |
3676 KB |
Output is correct |
5 |
Correct |
0 ms |
3676 KB |
Output is correct |
6 |
Correct |
0 ms |
3676 KB |
Output is correct |
7 |
Correct |
0 ms |
3676 KB |
Output is correct |
8 |
Correct |
0 ms |
3676 KB |
Output is correct |
9 |
Correct |
0 ms |
3676 KB |
Output is correct |
10 |
Correct |
0 ms |
3676 KB |
Output is correct |
11 |
Correct |
0 ms |
3676 KB |
Output is correct |
12 |
Correct |
44 ms |
3676 KB |
Output is correct |
13 |
Correct |
16 ms |
3676 KB |
Output is correct |
14 |
Correct |
20 ms |
3676 KB |
Output is correct |
15 |
Correct |
20 ms |
3676 KB |
Output is correct |