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 "closing.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n;
int qs[3030];
ll qsx[3030], qsy[3030], qsmx[3030];
ll vx[3030], vy[3030];
int max_score(int N, int X, int Y, ll K, vector<int> U, vector<int> V, vector<int> W) {
n = N;
int x = X + 1, y = Y + 1;
for (int i = 1;i < n;i++) {
qs[i] = qs[i - 1] + W[i - 1];
}
for (int i = 1;i <= n;i++) {
vx[i] = qs[max(x, i) - 1] - qs[min(x, i) - 1];
vy[i] = qs[max(y, i) - 1] - qs[min(y, i) - 1];
qsx[i] = qsx[i - 1] + vx[i];
qsy[i] = qsy[i - 1] + vy[i];
qsmx[i] = qsmx[i - 1] + max(vx[i], vy[i]);
}
int mx = 0;
for (int l1 = 1;l1 <= x;l1++) {
for (int r1 = x;r1 <= n;r1++) {
for (int l2 = 1;l2 <= y;l2++) {
for (int r2 = y;r2 <= n;r2++) {
ll val = 0;
if (l1 <= l2 && r2 <= r1) {
val += qsx[l2 - 1] - qsx[l1 - 1];
val += qsx[r1] - qsx[r2];
val += qsmx[r2] - qsmx[l2 - 1];
}
else if (l2 <= l1 && r1 <= r2) {
val += qsy[l1 - 1] - qsy[l2 - 1];
val += qsy[r2] - qsy[r1];
val += qsmx[r1] - qsmx[l1 - 1];
}
else if (r1 < l2) {
val += qsx[r1] - qsx[l1 - 1];
val += qsy[r2] - qsy[l2 - 1];
}
else {
val += qsx[l2 - 1] - qsx[l1 - 1];
val += qsy[r2] - qsy[r1];
val += qsmx[r1] - qsmx[l2 - 1];
}
if (val <= K) mx = max(mx, r1 - l1 + 1 + r2 - l2 + 1);
}
}
}
}
return mx;
}
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |