#include "friend.h"
#include <bits/stdc++.h>
#define fi first
#define se second
#define lo long long
#define inf 1000000000
#define md 1000000007
#define li 100005
#define mp make_pair
#define pb push_back
#define pi pair<lo int, int>
using namespace std;
int findSample(int n, int confidence[], int host[], int protocol[]){
int P[li], Q[li] = {0};
for(int i=0;i<n;i++){
P[i]=confidence[i];
}
for(int i=n-1;i>=1;i--){
int x=host[i];
int y=i;
if(protocol[i]==0){
Q[x]=max(Q[x]+Q[y],Q[x]+P[y]);
P[x]=P[x]+Q[y];
}
if(protocol[i]==1){
P[x]=max(P[x]+P[y],max(Q[x]+P[y],Q[y]+P[x]));
Q[x]=Q[x]+Q[y];
}
if(protocol[i]==2){
P[x]=max(P[x]+Q[y],Q[x]+P[y]);
Q[x]=Q[x]+Q[y];
}
}
return max(Q[0],P[0]);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
888 KB |
Output is correct |
2 |
Correct |
2 ms |
1048 KB |
Output is correct |
3 |
Correct |
2 ms |
1096 KB |
Output is correct |
4 |
Correct |
2 ms |
1116 KB |
Output is correct |
5 |
Correct |
2 ms |
1248 KB |
Output is correct |
6 |
Correct |
2 ms |
1248 KB |
Output is correct |
7 |
Correct |
2 ms |
1248 KB |
Output is correct |
8 |
Correct |
2 ms |
1248 KB |
Output is correct |
9 |
Correct |
3 ms |
1248 KB |
Output is correct |
10 |
Correct |
3 ms |
1260 KB |
Output is correct |
11 |
Correct |
3 ms |
1264 KB |
Output is correct |
12 |
Correct |
2 ms |
1268 KB |
Output is correct |
13 |
Correct |
3 ms |
1272 KB |
Output is correct |
14 |
Correct |
2 ms |
1276 KB |
Output is correct |
15 |
Correct |
3 ms |
1280 KB |
Output is correct |
16 |
Correct |
3 ms |
1284 KB |
Output is correct |
17 |
Correct |
2 ms |
1288 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1420 KB |
Output is correct |
2 |
Correct |
2 ms |
1420 KB |
Output is correct |
3 |
Correct |
3 ms |
1428 KB |
Output is correct |
4 |
Correct |
3 ms |
1436 KB |
Output is correct |
5 |
Correct |
3 ms |
1480 KB |
Output is correct |
6 |
Correct |
2 ms |
1508 KB |
Output is correct |
7 |
Correct |
3 ms |
1532 KB |
Output is correct |
8 |
Correct |
3 ms |
1540 KB |
Output is correct |
9 |
Correct |
3 ms |
1552 KB |
Output is correct |
10 |
Correct |
3 ms |
1576 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1592 KB |
Output is correct |
2 |
Correct |
3 ms |
1600 KB |
Output is correct |
3 |
Correct |
2 ms |
1612 KB |
Output is correct |
4 |
Correct |
2 ms |
1616 KB |
Output is correct |
5 |
Correct |
3 ms |
1628 KB |
Output is correct |
6 |
Correct |
2 ms |
1640 KB |
Output is correct |
7 |
Correct |
2 ms |
1644 KB |
Output is correct |
8 |
Correct |
2 ms |
1648 KB |
Output is correct |
9 |
Correct |
2 ms |
1656 KB |
Output is correct |
10 |
Correct |
3 ms |
1660 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1804 KB |
Output is correct |
2 |
Correct |
2 ms |
1812 KB |
Output is correct |
3 |
Correct |
2 ms |
1812 KB |
Output is correct |
4 |
Correct |
3 ms |
1816 KB |
Output is correct |
5 |
Correct |
3 ms |
1820 KB |
Output is correct |
6 |
Correct |
3 ms |
1828 KB |
Output is correct |
7 |
Correct |
2 ms |
1844 KB |
Output is correct |
8 |
Correct |
3 ms |
1848 KB |
Output is correct |
9 |
Correct |
2 ms |
1860 KB |
Output is correct |
10 |
Correct |
2 ms |
1864 KB |
Output is correct |
11 |
Correct |
3 ms |
1868 KB |
Output is correct |
12 |
Correct |
3 ms |
1876 KB |
Output is correct |
13 |
Correct |
3 ms |
1888 KB |
Output is correct |
14 |
Correct |
2 ms |
1980 KB |
Output is correct |
15 |
Correct |
3 ms |
1980 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1980 KB |
Output is correct |
2 |
Correct |
2 ms |
1980 KB |
Output is correct |
3 |
Correct |
3 ms |
1980 KB |
Output is correct |
4 |
Correct |
3 ms |
1980 KB |
Output is correct |
5 |
Correct |
3 ms |
1980 KB |
Output is correct |
6 |
Correct |
2 ms |
1980 KB |
Output is correct |
7 |
Correct |
2 ms |
1980 KB |
Output is correct |
8 |
Correct |
3 ms |
1980 KB |
Output is correct |
9 |
Correct |
3 ms |
1980 KB |
Output is correct |
10 |
Correct |
3 ms |
1980 KB |
Output is correct |
11 |
Correct |
2 ms |
1980 KB |
Output is correct |
12 |
Correct |
3 ms |
1980 KB |
Output is correct |
13 |
Correct |
3 ms |
1980 KB |
Output is correct |
14 |
Correct |
3 ms |
1980 KB |
Output is correct |
15 |
Correct |
3 ms |
1988 KB |
Output is correct |
16 |
Correct |
2 ms |
1992 KB |
Output is correct |
17 |
Correct |
2 ms |
1992 KB |
Output is correct |
18 |
Correct |
2 ms |
2000 KB |
Output is correct |
19 |
Correct |
2 ms |
2004 KB |
Output is correct |
20 |
Correct |
2 ms |
2008 KB |
Output is correct |
21 |
Correct |
2 ms |
2016 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2152 KB |
Output is correct |
2 |
Correct |
2 ms |
2152 KB |
Output is correct |
3 |
Correct |
3 ms |
2160 KB |
Output is correct |
4 |
Correct |
2 ms |
2164 KB |
Output is correct |
5 |
Correct |
2 ms |
2168 KB |
Output is correct |
6 |
Correct |
2 ms |
2168 KB |
Output is correct |
7 |
Correct |
2 ms |
2176 KB |
Output is correct |
8 |
Correct |
2 ms |
2180 KB |
Output is correct |
9 |
Correct |
2 ms |
2188 KB |
Output is correct |
10 |
Correct |
2 ms |
2316 KB |
Output is correct |
11 |
Correct |
2 ms |
2316 KB |
Output is correct |
12 |
Correct |
38 ms |
4920 KB |
Output is correct |
13 |
Correct |
20 ms |
4920 KB |
Output is correct |
14 |
Correct |
34 ms |
6488 KB |
Output is correct |
15 |
Correct |
34 ms |
7576 KB |
Output is correct |