#include "soccer.h"
#include <bits/stdc++.h>
using namespace std;
const int mxn=2006;
int n,ans,s[mxn][mxn];
vector <int> dp[mxn][mxn],l[mxn][mxn],r[mxn][mxn];
int sum(int l, int r, int i){
return s[r][i]-s[l][i];
}
int biggest_stadium(int N, vector <vector <int>> F){
n=N;
int S=0;
for (int i=0;i<n;i++)
for (int j=0;j<n;j++){
s[i+1][j]=s[i][j]+F[i][j];
if (!F[i][j])
S=j;
}
for (int k=(n<=500?0:S);k<=(n<=500?n:S);k++)
for (int i=0;i<=n;i++){
int x=k,y=k;
for (int j=n;j>=i;j--){
while (x&&!sum(i,j,x-1))
x--;
l[i][j].push_back(x);
while (y<n&&!sum(i,j,y))
y++;
r[i][j].push_back(y);
dp[i][j].assign((n<=500?n:0),0);
}
}
for (int L=0;L<n;L++)
for (int i=0;i+L+1<=n;i++)
for (int k=0;k<=(n<=500?n:0);k++){
int j=i+L+1;
dp[i][j][k]=max(dp[i+1][j][k]+(l[i][j][k]-l[i+1][j][k]+r[i+1][j][k]-r[i][j][k])*L,dp[i][j-1][k]+(l[i][j][k]-l[i][j-1][k]+r[i][j-1][k]-r[i][j][k])*L);
}
for (int i=0;i<=(n<=500?n:0);i++)
ans=max(ans,dp[0][n][i]+(r[0][n][i]-l[0][n][i])*n);
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
110 ms |
285932 KB |
ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
61 ms |
285872 KB |
ok |
2 |
Correct |
63 ms |
285780 KB |
ok |
3 |
Correct |
62 ms |
285780 KB |
ok |
4 |
Runtime error |
291 ms |
579068 KB |
Execution killed with signal 11 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
61 ms |
285872 KB |
ok |
2 |
Correct |
63 ms |
285780 KB |
ok |
3 |
Correct |
62 ms |
285780 KB |
ok |
4 |
Correct |
61 ms |
285776 KB |
ok |
5 |
Correct |
60 ms |
285716 KB |
ok |
6 |
Correct |
60 ms |
285780 KB |
ok |
7 |
Correct |
60 ms |
285776 KB |
ok |
8 |
Correct |
69 ms |
285776 KB |
ok |
9 |
Correct |
63 ms |
285776 KB |
ok |
10 |
Correct |
66 ms |
286032 KB |
ok |
11 |
Correct |
62 ms |
285736 KB |
ok |
12 |
Correct |
61 ms |
285628 KB |
ok |
13 |
Correct |
60 ms |
285780 KB |
ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
110 ms |
285932 KB |
ok |
2 |
Correct |
61 ms |
285872 KB |
ok |
3 |
Correct |
63 ms |
285780 KB |
ok |
4 |
Correct |
62 ms |
285780 KB |
ok |
5 |
Correct |
61 ms |
285776 KB |
ok |
6 |
Correct |
60 ms |
285716 KB |
ok |
7 |
Correct |
60 ms |
285780 KB |
ok |
8 |
Correct |
60 ms |
285776 KB |
ok |
9 |
Correct |
69 ms |
285776 KB |
ok |
10 |
Correct |
63 ms |
285776 KB |
ok |
11 |
Correct |
66 ms |
286032 KB |
ok |
12 |
Correct |
62 ms |
285736 KB |
ok |
13 |
Correct |
61 ms |
285628 KB |
ok |
14 |
Correct |
60 ms |
285780 KB |
ok |
15 |
Correct |
61 ms |
285676 KB |
ok |
16 |
Correct |
62 ms |
285780 KB |
ok |
17 |
Correct |
61 ms |
285784 KB |
ok |
18 |
Correct |
64 ms |
285780 KB |
ok |
19 |
Correct |
62 ms |
285780 KB |
ok |
20 |
Correct |
61 ms |
285780 KB |
ok |
21 |
Correct |
62 ms |
285608 KB |
ok |
22 |
Correct |
71 ms |
285776 KB |
ok |
23 |
Correct |
73 ms |
285732 KB |
ok |
24 |
Correct |
62 ms |
285780 KB |
ok |
25 |
Correct |
62 ms |
285780 KB |
ok |
26 |
Correct |
62 ms |
285660 KB |
ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
110 ms |
285932 KB |
ok |
2 |
Correct |
61 ms |
285872 KB |
ok |
3 |
Correct |
63 ms |
285780 KB |
ok |
4 |
Correct |
62 ms |
285780 KB |
ok |
5 |
Runtime error |
291 ms |
579068 KB |
Execution killed with signal 11 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
110 ms |
285932 KB |
ok |
2 |
Correct |
61 ms |
285872 KB |
ok |
3 |
Correct |
63 ms |
285780 KB |
ok |
4 |
Correct |
62 ms |
285780 KB |
ok |
5 |
Runtime error |
291 ms |
579068 KB |
Execution killed with signal 11 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
110 ms |
285932 KB |
ok |
2 |
Correct |
61 ms |
285872 KB |
ok |
3 |
Correct |
63 ms |
285780 KB |
ok |
4 |
Correct |
62 ms |
285780 KB |
ok |
5 |
Runtime error |
291 ms |
579068 KB |
Execution killed with signal 11 |
6 |
Halted |
0 ms |
0 KB |
- |