#include "friend.h"
// mrrrow meeow :3
// go play vivid/stasis! it's an awesome free game on steam
int vs[100000][2];
int max(int a, int b) { return a > b ? a : b; }
int findSample(int n, int confidence[], int host[], int protocol[]) {
for (int i = 0; i < n; i++) vs[i][1] = confidence[i];
for (int i = n; i-- > 1;) {
int j = host[i];
int nx = vs[j][0], cx = vs[j][1];
int ny = vs[i][0], cy = vs[i][1];
switch (protocol[i]) {
case 0:
vs[j][0] = max(nx + ny, nx + cy);
vs[j][1] = cx + ny;
break;
case 1:
vs[j][0] = nx + ny;
vs[j][1] = max(cx + cy, max(cx + ny, nx + cy));
break;
case 2:
vs[j][0] = nx + ny;
vs[j][1] = max(cx + ny, nx + cy);
break;
}
}
return max(vs[0][0], vs[0][1]);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |