이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mxn = 1e5 + 5;
ll n, m, w[mxn], dp[mxn][2][2][2], res = 0;
ll max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) {
n = N, m = M;
for (int i = 0; i < m; i++) w[X[i] + 1] = W[i];
if (n < 3) return max(w[1], w[2]);
dp[3][0][0][0] = 0;
dp[3][0][0][1] = w[2];
dp[3][0][1][0] = w[1];
dp[3][0][1][1] = w[1];
dp[3][1][0][0] = w[2];
dp[3][1][0][1] = w[2];
dp[3][1][1][0] = 0;
dp[3][1][1][1] = 0;
for (int i = 4; i <= n; i++) {
for (int h = 0; h <= 1; h++) for (int h1 = 0; h1 <= 1; h1++) for (int h2 = 0; h2 <= 1; h2++) {
for (int h3 = 0; h3 <= 1; h3++) {
dp[i][h2][h1][h] = max(dp[i][h2][h1][h], dp[i - 1][h3][h2][h1] + ((h2 || h) && !h1 ? w[i - 1] : 0));
}
}
}
for (int h = 0; h <= 1; h++) for (int h1 = 0; h1 <= 1; h1++) for (int h2 = 0; h2 <= 1; h2++) {
res = max(res, dp[n][h2][h1][h] + (h1 && !h ? w[n] : 0));
}
return res;
}
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |