#include "closing.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n;
ll 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) { // 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) { // l1 .. r1 .. l2 .. r2
val += qsx[r1] - qsx[l1 - 1];
val += qsy[r2] - qsy[l2 - 1];
}
else if (l1 <= l2 && l2 <= r1 && r1 <= r2) { // l1 .. l2 .. r1 .. r2
val += qsx[l2 - 1] - qsx[l1 - 1];
val += qsy[r2] - qsy[r1];
val += qsmx[r1] - qsmx[l2 - 1];
}
else { // l2 .. l1 .. r2 .. r1
val += qsy[l1 - 1] - qsy[l2 - 1];
val += qsx[r1] - qsx[r2];
val += qsmx[r2] - qsmx[l1 - 1];
}
if (val <= K) mx = max(mx, r1 - l1 + 1 + r2 - l2 + 1);
}
}
}
}
return mx;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
600 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
40 ms |
10068 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
3 ms |
348 KB |
Output is correct |
13 |
Correct |
2 ms |
348 KB |
Output is correct |
14 |
Correct |
6 ms |
348 KB |
Output is correct |
15 |
Correct |
4 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
344 KB |
Output is correct |
19 |
Execution timed out |
1057 ms |
448 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
3 ms |
348 KB |
Output is correct |
13 |
Correct |
2 ms |
348 KB |
Output is correct |
14 |
Correct |
6 ms |
348 KB |
Output is correct |
15 |
Correct |
4 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
344 KB |
Output is correct |
19 |
Execution timed out |
1057 ms |
448 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
600 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
600 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
600 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
600 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
600 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |