This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// https://github.com/tmwilliamlin168/CompetitiveProgramming/blob/master/IOI/14-Friend.cpp
#include "friend.h"
#include <bits/stdc++.h>
using namespace std;
int findSample(int n, int *c, int *h, int *p){
vector dp(2, vector<int>(n));
dp[1] = vector<int>(c, c + n);
while (--n) {
if (!p[n]) {
dp[0][h[n]] += dp[1][n];
dp[1][h[n]] += dp[0][n];
} else if (p[n] == 1) {
dp[0][h[n]] += dp[0][n];
dp[1][h[n]] += dp[1][n];
} else {
dp[1][h[n]] = max(dp[0][n] + dp[1][h[n]], dp[1][n] + dp[0][h[n]]);
dp[0][h[n]] += dp[0][n];
}
dp[1][h[n]] = max(dp[1][h[n]], dp[0][h[n]]);
}
return dp[1][0];
}
# | 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... |