#include <bits/stdc++.h>
#include "closing.h"
using namespace std;
typedef long long ll;
int max_score(int n, int x, int y, ll k, vector<int> u, vector<int> v, vector<int> w) {
vector<ll> distX(n), distY(n), totX(n), totY(n);
for (int i = x-1; i >= 0; i--) {
distX[i] = distX[i+1] + w[i];
totX[i] = totX[i+1] + distX[i];
}
for (int i = x+1; i < n; i++) {
distX[i] = distX[i-1] + w[i-1];
totX[i] = totX[i-1] + distX[i];
}
for (int i = y-1; i >= 0; i--) {
distY[i] = distY[i+1] + w[i];
totY[i] = totY[i+1] + distY[i];
}
for (int i = y+1; i < n; i++) {
distY[i] = distY[i-1] + w[i-1];
totY[i] = totY[i-1] + distY[i];
}
vector<ll> mx(n), mxSum(n+1);
for (int i = 0; i < n; i++) {
mx[i] = max(distX[i], distY[i]);
mxSum[i+1] = mxSum[i] + mx[i];
}
ll res = 0;
for (int x1 = 0; x1 <= x; x1++) {
for (int y1 = x1; y1 <= y; y1++) {
for (int y2 = y; y2 < n; y2++) {
for (int x2 = x; x2 <= y2; x2++) {
ll val = x2-x1+1 + y2-y1+1;
if (val <= res) continue;
ll cost = 1ll << 62ll;
if (x2 < y1) {
cost = totX[x1] + totX[x2] + totY[y1] + totY[y2];
}
else {
cost = totX[x1] + (y1 < x ? -totX[y1-1] : totX[y1-1]) + (x2 > y ? -totY[x2+1] : totY[x2+1]) + totY[y2]
+ (mxSum[x2+1] - mxSum[y1]);
}
if (cost <= k) res = val;
else break;
}
}
}
}
return res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1080 ms |
14320 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '30', found: '34' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '30', found: '34' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '30', found: '34' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '30', found: '34' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '30', found: '34' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '30', found: '34' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '30', found: '34' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '30', found: '34' |
4 |
Halted |
0 ms |
0 KB |
- |