#include "closing.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int max_score(int N, int X, int Y, ll K, vector<int> U, vector<int> V, vector<int> W) {
vector<ll> pfs(N);
for (int i = 0; i < N - 1; i++) {
pfs[i + 1] = pfs[i] + W[i];
}
auto dis = [&](int x, int y) {
if (x > y) swap(x, y);
return pfs[y] - pfs[x];
};
vector<ll> one(N), two(N), sx(N + 1), sy(N + 1), s2(N + 1), s1(N + 1);
for (int i = 0; i < N; i++) {
tie(one[i], two[i]) = minmax(dis(X, i), dis(Y, i));
sx[i + 1] = sx[i] + dis(X, i);
sy[i + 1] = sy[i] + dis(Y, i);
s1[i + 1] = s1[i] + one[i];
s2[i + 1] = s2[i] + two[i];
}
int ans = 0;
for (int lx = 0; lx <= X; lx++) {
for (int rx = X; rx < N; rx++) {
for (int ly = 0; ly <= Y; ly++) {
for (int ry = Y; ry < N; ry++) {
int L = max(lx, ly);
int R = min(rx, ry);
if (sx[rx + 1] - sx[lx] + sy[ry + 1] - sy[ly] - (L <= R ? one[R + 1] - one[L] : 0) <= K) {
ans = max(ans, rx - lx + 1 + ry - ly + 1);
}
}
}
}
}
// for (int l2 = 0; l2 < N; l2++) {
// for (int r2 = l2; r2 < N; r2++) {
// for (int l1 = 0; l1 <= min(X, l2); l1++) {
// for (int r1 = max(Y, r2); r1 < N; r1++) {
// if (s2[r2 + 1] - s2[l2] + sx[l2] - sx[l1] + sy[r1] - sy[r2] <= K) {
// ans = max(ans, r1 - l1 + 1 + r2 - l2 + 1);
// }
// }
// }
// }
// }
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1061 ms |
19540 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
1st lines differ - on the 1st token, expected: '3', found: '6' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
1st lines differ - on the 1st token, expected: '3', found: '6' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
1st lines differ - on the 1st token, expected: '3', found: '6' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |