#include "closing.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector <ll>;
using vi = vector <int>;
const ll MAXN = 2E5+16;
int max_score (int n, int u1, int u2, ll k, vi u, vi v, vi w) {
vi ve(w);
vi f1(n, 0), f2(n, 0);
f1[u1] = 0;
f2[u2] = 0;
for (int u = u1+1; u < n; u++)
f1[u] = f1[u-1] + w[u-1];
for (int u = u1-1; u >= 0; u--)
f1[u] = f1[u+1] + w[u];
for (int u = u2+1; u < n; u++)
f2[u] = f2[u-1] + w[u-1];
for (int u = u2-1; u >= 0; u--)
f2[u] = f2[u+1] + w[u];
int ans = 0;
for (int l1 = 0; l1 <= u1; l1++)
for (int r1 = u1; r1 < n; r1++) {
for (int l2 = 0; l2 <= u2; l2++)
for (int r2 = u2; r2 < n; r2++) {
ll cost = 0;
for (int i = l1; i <= r1; i++) {
if (l2 <= i && i <= r2)
cost += max(f1[i], f2[i]);
else
cost += f1[i];
}
for (int i = l2; i <= r2; i++) {
if (l1 <= i && i <= r1) continue;
cost += f2[i];
}
if (cost <= 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 |
1040 ms |
7248 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
436 KB |
Output is correct |
6 |
Correct |
30 ms |
344 KB |
Output is correct |
7 |
Correct |
22 ms |
344 KB |
Output is correct |
8 |
Correct |
8 ms |
348 KB |
Output is correct |
9 |
Correct |
2 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
436 KB |
Output is correct |
6 |
Correct |
30 ms |
344 KB |
Output is correct |
7 |
Correct |
22 ms |
344 KB |
Output is correct |
8 |
Correct |
8 ms |
348 KB |
Output is correct |
9 |
Correct |
2 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
93 ms |
348 KB |
Output is correct |
13 |
Correct |
57 ms |
344 KB |
Output is correct |
14 |
Correct |
196 ms |
416 KB |
Output is correct |
15 |
Correct |
80 ms |
664 KB |
Output is correct |
16 |
Correct |
2 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
600 KB |
Output is correct |
18 |
Correct |
8 ms |
344 KB |
Output is correct |
19 |
Execution timed out |
1069 ms |
348 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
436 KB |
Output is correct |
6 |
Correct |
30 ms |
344 KB |
Output is correct |
7 |
Correct |
22 ms |
344 KB |
Output is correct |
8 |
Correct |
8 ms |
348 KB |
Output is correct |
9 |
Correct |
2 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
93 ms |
348 KB |
Output is correct |
13 |
Correct |
57 ms |
344 KB |
Output is correct |
14 |
Correct |
196 ms |
416 KB |
Output is correct |
15 |
Correct |
80 ms |
664 KB |
Output is correct |
16 |
Correct |
2 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
600 KB |
Output is correct |
18 |
Correct |
8 ms |
344 KB |
Output is correct |
19 |
Execution timed out |
1069 ms |
348 KB |
Time limit exceeded |
20 |
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 |
- |