#include "soccer.h"
#include <bits/stdc++.h>
using namespace std;
int biggest_stadium(int N, std::vector<std::vector<int>> F)
{
int ans = 0;
for (int _ = 0; _ < N; _++){
int left[N]={};
int right[N]={};
for (int j = 0; j < N; j++){
for (int i = _+1; i < N; i++){
if (!F[i][j]){
right[j]++;
}
else break;
}
for (int i = _; i >= 0; i--){
if (!F[i][j]){
left[j]++;
}
else break;
}
}
vector<vector<int>> minl(N,vector<int>(N));
vector<vector<int>> minr(N,vector<int>(N));
for (int i = 0; i < N; i++){
minl[i][i]=left[i];
minr[i][i]=right[i];
for (int j = i+1; j < N; j++){
minl[i][j]=min(minl[i][j-1],left[j]);
minr[i][j]=min(minr[i][j-1],right[j]);
}
}
for (int i = 0; i < N; i++){
vector<vector<int>> dp(N,vector<int>(N,-1));
function<int(int,int)> f = [&](int lef, int rig)->int{
if (dp[lef][rig]!=-1) return dp[lef][rig];
dp[lef][rig]=0;
if (i-lef-1>=0){
//leftten al
int cur = minl[i-lef-1][i+rig]+minr[i-lef-1][i+rig];
dp[lef][rig]=max(dp[lef][rig],f(lef+1,rig)+cur);
}
if (i+rig+1<N) {
//righttan al
int cur = minl[i-lef][i+rig+1]+minr[i-lef][i+rig+1];
dp[lef][rig]=max(dp[lef][rig],f(lef,rig+1)+cur);
}
return dp[lef][rig];
};
ans=max(ans,f(0,0)+right[i]+left[i]);
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
ok |
2 |
Correct |
1 ms |
348 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Correct |
0 ms |
348 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Correct |
0 ms |
348 KB |
ok |
7 |
Correct |
355 ms |
628 KB |
ok |
8 |
Execution timed out |
4503 ms |
6256 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
ok |
2 |
Correct |
1 ms |
348 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Correct |
0 ms |
348 KB |
ok |
5 |
Correct |
0 ms |
680 KB |
ok |
6 |
Correct |
0 ms |
344 KB |
ok |
7 |
Correct |
0 ms |
348 KB |
ok |
8 |
Correct |
0 ms |
348 KB |
ok |
9 |
Correct |
0 ms |
348 KB |
ok |
10 |
Correct |
0 ms |
348 KB |
ok |
11 |
Correct |
0 ms |
348 KB |
ok |
12 |
Correct |
0 ms |
348 KB |
ok |
13 |
Correct |
0 ms |
348 KB |
ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
ok |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
1 ms |
348 KB |
ok |
4 |
Correct |
0 ms |
348 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Correct |
0 ms |
680 KB |
ok |
7 |
Correct |
0 ms |
344 KB |
ok |
8 |
Correct |
0 ms |
348 KB |
ok |
9 |
Correct |
0 ms |
348 KB |
ok |
10 |
Correct |
0 ms |
348 KB |
ok |
11 |
Correct |
0 ms |
348 KB |
ok |
12 |
Correct |
0 ms |
348 KB |
ok |
13 |
Correct |
0 ms |
348 KB |
ok |
14 |
Correct |
0 ms |
348 KB |
ok |
15 |
Correct |
0 ms |
348 KB |
ok |
16 |
Correct |
0 ms |
348 KB |
ok |
17 |
Correct |
0 ms |
348 KB |
ok |
18 |
Correct |
0 ms |
348 KB |
ok |
19 |
Correct |
0 ms |
348 KB |
ok |
20 |
Correct |
0 ms |
348 KB |
ok |
21 |
Correct |
1 ms |
348 KB |
ok |
22 |
Correct |
1 ms |
348 KB |
ok |
23 |
Correct |
0 ms |
348 KB |
ok |
24 |
Correct |
0 ms |
348 KB |
ok |
25 |
Correct |
0 ms |
344 KB |
ok |
26 |
Correct |
0 ms |
348 KB |
ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
ok |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
1 ms |
348 KB |
ok |
4 |
Correct |
0 ms |
348 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Correct |
0 ms |
348 KB |
ok |
7 |
Correct |
0 ms |
348 KB |
ok |
8 |
Correct |
0 ms |
680 KB |
ok |
9 |
Correct |
0 ms |
344 KB |
ok |
10 |
Correct |
0 ms |
348 KB |
ok |
11 |
Correct |
0 ms |
348 KB |
ok |
12 |
Correct |
0 ms |
348 KB |
ok |
13 |
Correct |
0 ms |
348 KB |
ok |
14 |
Correct |
0 ms |
348 KB |
ok |
15 |
Correct |
0 ms |
348 KB |
ok |
16 |
Correct |
0 ms |
348 KB |
ok |
17 |
Correct |
0 ms |
348 KB |
ok |
18 |
Correct |
0 ms |
348 KB |
ok |
19 |
Correct |
0 ms |
348 KB |
ok |
20 |
Correct |
0 ms |
348 KB |
ok |
21 |
Correct |
0 ms |
348 KB |
ok |
22 |
Correct |
0 ms |
348 KB |
ok |
23 |
Correct |
1 ms |
348 KB |
ok |
24 |
Correct |
1 ms |
348 KB |
ok |
25 |
Correct |
0 ms |
348 KB |
ok |
26 |
Correct |
0 ms |
348 KB |
ok |
27 |
Correct |
0 ms |
344 KB |
ok |
28 |
Correct |
0 ms |
348 KB |
ok |
29 |
Correct |
0 ms |
348 KB |
ok |
30 |
Correct |
4 ms |
348 KB |
ok |
31 |
Correct |
4 ms |
348 KB |
ok |
32 |
Correct |
4 ms |
344 KB |
ok |
33 |
Correct |
4 ms |
348 KB |
ok |
34 |
Correct |
4 ms |
348 KB |
ok |
35 |
Correct |
4 ms |
344 KB |
ok |
36 |
Correct |
4 ms |
348 KB |
ok |
37 |
Correct |
4 ms |
348 KB |
ok |
38 |
Correct |
4 ms |
348 KB |
ok |
39 |
Correct |
4 ms |
348 KB |
ok |
40 |
Correct |
4 ms |
356 KB |
ok |
41 |
Correct |
4 ms |
348 KB |
ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
ok |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
1 ms |
348 KB |
ok |
4 |
Correct |
0 ms |
348 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Correct |
0 ms |
348 KB |
ok |
7 |
Correct |
0 ms |
348 KB |
ok |
8 |
Correct |
0 ms |
680 KB |
ok |
9 |
Correct |
0 ms |
344 KB |
ok |
10 |
Correct |
0 ms |
348 KB |
ok |
11 |
Correct |
0 ms |
348 KB |
ok |
12 |
Correct |
0 ms |
348 KB |
ok |
13 |
Correct |
0 ms |
348 KB |
ok |
14 |
Correct |
0 ms |
348 KB |
ok |
15 |
Correct |
0 ms |
348 KB |
ok |
16 |
Correct |
0 ms |
348 KB |
ok |
17 |
Correct |
0 ms |
348 KB |
ok |
18 |
Correct |
0 ms |
348 KB |
ok |
19 |
Correct |
0 ms |
348 KB |
ok |
20 |
Correct |
0 ms |
348 KB |
ok |
21 |
Correct |
0 ms |
348 KB |
ok |
22 |
Correct |
0 ms |
348 KB |
ok |
23 |
Correct |
1 ms |
348 KB |
ok |
24 |
Correct |
1 ms |
348 KB |
ok |
25 |
Correct |
0 ms |
348 KB |
ok |
26 |
Correct |
0 ms |
348 KB |
ok |
27 |
Correct |
0 ms |
344 KB |
ok |
28 |
Correct |
0 ms |
348 KB |
ok |
29 |
Correct |
0 ms |
348 KB |
ok |
30 |
Correct |
4 ms |
348 KB |
ok |
31 |
Correct |
4 ms |
348 KB |
ok |
32 |
Correct |
4 ms |
344 KB |
ok |
33 |
Correct |
4 ms |
348 KB |
ok |
34 |
Correct |
4 ms |
348 KB |
ok |
35 |
Correct |
4 ms |
344 KB |
ok |
36 |
Correct |
4 ms |
348 KB |
ok |
37 |
Correct |
4 ms |
348 KB |
ok |
38 |
Correct |
4 ms |
348 KB |
ok |
39 |
Correct |
4 ms |
348 KB |
ok |
40 |
Correct |
4 ms |
356 KB |
ok |
41 |
Correct |
4 ms |
348 KB |
ok |
42 |
Execution timed out |
4584 ms |
5964 KB |
Time limit exceeded |
43 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
ok |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
1 ms |
348 KB |
ok |
4 |
Correct |
0 ms |
348 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Correct |
0 ms |
348 KB |
ok |
7 |
Correct |
0 ms |
348 KB |
ok |
8 |
Correct |
355 ms |
628 KB |
ok |
9 |
Execution timed out |
4503 ms |
6256 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |