이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <tuple>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
const ll SZ = 2e5 + 100;
ll dp[SZ][2], svd[SZ][2]; // 0 for dont take, 1 for take
//int confidence[SZ], host[SZ], protocol[SZ];
int findSample(int n, int confidence[], int host[], int protocol[]) {
for (int i = n - 1; i >= 0; i--) dp[i][1] += confidence[i];
for (int i = n - 1; i >= 0; i--) {
dp[i][1] = max(dp[i][1], dp[i][0]);
if (i == 0) continue;
if (protocol[i] == 0) {
dp[host[i]][0] += dp[i][1];
dp[host[i]][1] += dp[i][0];
dp[host[i]][1] = max(dp[host[i]][1], dp[host[i]][0]);
} else if (protocol[i] == 1) {
ll sv = dp[host[i]][0];
dp[host[i]][0] += dp[i][0];
dp[host[i]][1] += dp[i][1];
dp[host[i]][1] = max(dp[host[i]][1], sv + dp[i][1]);
dp[host[i]][1] = max(dp[host[i]][1], dp[host[i]][0]);
} else {
ll sv = dp[host[i]][0];
dp[host[i]][0] += dp[i][0];
dp[host[i]][1] = max(dp[host[i]][1] + dp[i][0], sv + dp[i][1]);
}
}
return dp[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... |