This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
/// #pragma GCC optimize ("Ofast")
/// #pragma GCC target ("avx2")
/// #pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
using ld = long double;
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lb lower_bound
const int MOD = 998244353;
int DP[100001][2];
int findSample(int N, int* confidence,
int* host, int* protocol) {
for(int l = 0; l < N; l++)
DP[l][1] = confidence[l];
for(int l = N - 1; l > 0; l--) {
int t = protocol[l];
if(t == 0) {
DP[host[l]][0] += DP[l][1];
DP[host[l]][1] += DP[l][0];
}
if(t == 1) {
DP[host[l]][1] += DP[l][1];
DP[host[l]][0] += DP[l][0];
}
if(t == 2) {
DP[host[l]][1] = max(DP[host[l]][0] + DP[l][1], DP[host[l]][1] + DP[l][0]);
DP[host[l]][0] += DP[l][0];
}
DP[host[l]][1] = max(DP[host[l]][1], DP[host[l]][0]);
}
return max(DP[0][0], 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... |