#include <bits/stdc++.h>
#include "soccer.h"
using namespace std;
int biggest_stadium(int N, vector<vector<int>> F){
vector<int> H(N), oldDp(N);
vector<vector<int>> byH(N+1);
int ans = 0;
for(int i = 0; i < N; i++){
for(int j = 0; j < N; j++){
if(F[i][j]) H[j] = 0;
else H[j]++;
byH[H[j]].push_back(j);
}
stack<pair<int, int>> s;
s.emplace(-1, -1);
vector<int> L(N), R(N, N), dp(N);
for(int k = 0; k < N; k++){
while(s.top().first > H[k]){
R[s.top().second] = k;
s.pop();
}
if(s.top().first == H[k]) L[k] = L[s.top().second];
else L[k] = s.top().second+1;
s.emplace(H[k], k);
}
for(int h = 1; h <= i+1; h++){
for(int j : byH[h]){
int w = R[j]-L[j];
dp[j] = w+oldDp[j];
if(int k = L[j]-1; k >= 0) dp[j] = max(dp[j], w*(H[j]-H[k]) + dp[k]);
if(int k = R[j]; k < N) dp[j] = max(dp[j], w*(H[j]-H[k]) + dp[k]);
ans = max(ans, dp[j]);
}
byH[h].clear();
}
swap(dp, oldDp);
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
500 KB |
ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
ok |
2 |
Correct |
1 ms |
344 KB |
ok |
3 |
Correct |
0 ms |
344 KB |
ok |
4 |
Correct |
0 ms |
344 KB |
ok |
5 |
Correct |
0 ms |
344 KB |
ok |
6 |
Correct |
0 ms |
344 KB |
ok |
7 |
Correct |
1 ms |
344 KB |
ok |
8 |
Correct |
31 ms |
3412 KB |
ok |
9 |
Correct |
286 ms |
48408 KB |
ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
ok |
2 |
Correct |
1 ms |
344 KB |
ok |
3 |
Correct |
0 ms |
344 KB |
ok |
4 |
Correct |
1 ms |
344 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Correct |
0 ms |
344 KB |
ok |
7 |
Correct |
0 ms |
344 KB |
ok |
8 |
Correct |
0 ms |
344 KB |
ok |
9 |
Correct |
0 ms |
344 KB |
ok |
10 |
Correct |
0 ms |
344 KB |
ok |
11 |
Correct |
0 ms |
344 KB |
ok |
12 |
Correct |
0 ms |
344 KB |
ok |
13 |
Correct |
1 ms |
500 KB |
ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
500 KB |
ok |
2 |
Correct |
0 ms |
344 KB |
ok |
3 |
Correct |
1 ms |
344 KB |
ok |
4 |
Correct |
0 ms |
344 KB |
ok |
5 |
Correct |
1 ms |
344 KB |
ok |
6 |
Correct |
0 ms |
348 KB |
ok |
7 |
Correct |
0 ms |
344 KB |
ok |
8 |
Correct |
0 ms |
344 KB |
ok |
9 |
Correct |
0 ms |
344 KB |
ok |
10 |
Correct |
0 ms |
344 KB |
ok |
11 |
Correct |
0 ms |
344 KB |
ok |
12 |
Correct |
0 ms |
344 KB |
ok |
13 |
Correct |
0 ms |
344 KB |
ok |
14 |
Correct |
1 ms |
500 KB |
ok |
15 |
Correct |
0 ms |
344 KB |
ok |
16 |
Correct |
0 ms |
344 KB |
ok |
17 |
Correct |
0 ms |
544 KB |
ok |
18 |
Correct |
1 ms |
344 KB |
ok |
19 |
Correct |
0 ms |
344 KB |
ok |
20 |
Correct |
0 ms |
344 KB |
ok |
21 |
Correct |
0 ms |
344 KB |
ok |
22 |
Correct |
0 ms |
344 KB |
ok |
23 |
Correct |
1 ms |
344 KB |
ok |
24 |
Correct |
0 ms |
344 KB |
ok |
25 |
Correct |
0 ms |
344 KB |
ok |
26 |
Correct |
0 ms |
344 KB |
ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
500 KB |
ok |
2 |
Correct |
0 ms |
344 KB |
ok |
3 |
Correct |
1 ms |
344 KB |
ok |
4 |
Correct |
0 ms |
344 KB |
ok |
5 |
Correct |
0 ms |
344 KB |
ok |
6 |
Correct |
0 ms |
344 KB |
ok |
7 |
Correct |
1 ms |
344 KB |
ok |
8 |
Correct |
0 ms |
348 KB |
ok |
9 |
Correct |
0 ms |
344 KB |
ok |
10 |
Correct |
0 ms |
344 KB |
ok |
11 |
Correct |
0 ms |
344 KB |
ok |
12 |
Correct |
0 ms |
344 KB |
ok |
13 |
Correct |
0 ms |
344 KB |
ok |
14 |
Correct |
0 ms |
344 KB |
ok |
15 |
Correct |
0 ms |
344 KB |
ok |
16 |
Correct |
1 ms |
500 KB |
ok |
17 |
Correct |
0 ms |
344 KB |
ok |
18 |
Correct |
0 ms |
344 KB |
ok |
19 |
Correct |
0 ms |
544 KB |
ok |
20 |
Correct |
1 ms |
344 KB |
ok |
21 |
Correct |
0 ms |
344 KB |
ok |
22 |
Correct |
0 ms |
344 KB |
ok |
23 |
Correct |
0 ms |
344 KB |
ok |
24 |
Correct |
0 ms |
344 KB |
ok |
25 |
Correct |
1 ms |
344 KB |
ok |
26 |
Correct |
0 ms |
344 KB |
ok |
27 |
Correct |
0 ms |
344 KB |
ok |
28 |
Correct |
0 ms |
344 KB |
ok |
29 |
Correct |
0 ms |
344 KB |
ok |
30 |
Correct |
0 ms |
344 KB |
ok |
31 |
Correct |
0 ms |
344 KB |
ok |
32 |
Correct |
0 ms |
348 KB |
ok |
33 |
Correct |
1 ms |
348 KB |
ok |
34 |
Correct |
0 ms |
344 KB |
ok |
35 |
Correct |
1 ms |
344 KB |
ok |
36 |
Correct |
0 ms |
344 KB |
ok |
37 |
Correct |
0 ms |
344 KB |
ok |
38 |
Correct |
0 ms |
344 KB |
ok |
39 |
Correct |
0 ms |
344 KB |
ok |
40 |
Correct |
1 ms |
344 KB |
ok |
41 |
Correct |
1 ms |
348 KB |
ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
500 KB |
ok |
2 |
Correct |
0 ms |
344 KB |
ok |
3 |
Correct |
1 ms |
344 KB |
ok |
4 |
Correct |
0 ms |
344 KB |
ok |
5 |
Correct |
0 ms |
344 KB |
ok |
6 |
Correct |
0 ms |
344 KB |
ok |
7 |
Correct |
1 ms |
344 KB |
ok |
8 |
Correct |
0 ms |
348 KB |
ok |
9 |
Correct |
0 ms |
344 KB |
ok |
10 |
Correct |
0 ms |
344 KB |
ok |
11 |
Correct |
0 ms |
344 KB |
ok |
12 |
Correct |
0 ms |
344 KB |
ok |
13 |
Correct |
0 ms |
344 KB |
ok |
14 |
Correct |
0 ms |
344 KB |
ok |
15 |
Correct |
0 ms |
344 KB |
ok |
16 |
Correct |
1 ms |
500 KB |
ok |
17 |
Correct |
0 ms |
344 KB |
ok |
18 |
Correct |
0 ms |
344 KB |
ok |
19 |
Correct |
0 ms |
544 KB |
ok |
20 |
Correct |
1 ms |
344 KB |
ok |
21 |
Correct |
0 ms |
344 KB |
ok |
22 |
Correct |
0 ms |
344 KB |
ok |
23 |
Correct |
0 ms |
344 KB |
ok |
24 |
Correct |
0 ms |
344 KB |
ok |
25 |
Correct |
1 ms |
344 KB |
ok |
26 |
Correct |
0 ms |
344 KB |
ok |
27 |
Correct |
0 ms |
344 KB |
ok |
28 |
Correct |
0 ms |
344 KB |
ok |
29 |
Correct |
0 ms |
344 KB |
ok |
30 |
Correct |
0 ms |
344 KB |
ok |
31 |
Correct |
0 ms |
344 KB |
ok |
32 |
Correct |
0 ms |
348 KB |
ok |
33 |
Correct |
1 ms |
348 KB |
ok |
34 |
Correct |
0 ms |
344 KB |
ok |
35 |
Correct |
1 ms |
344 KB |
ok |
36 |
Correct |
0 ms |
344 KB |
ok |
37 |
Correct |
0 ms |
344 KB |
ok |
38 |
Correct |
0 ms |
344 KB |
ok |
39 |
Correct |
0 ms |
344 KB |
ok |
40 |
Correct |
1 ms |
344 KB |
ok |
41 |
Correct |
1 ms |
348 KB |
ok |
42 |
Correct |
20 ms |
2648 KB |
ok |
43 |
Correct |
22 ms |
2772 KB |
ok |
44 |
Correct |
21 ms |
2664 KB |
ok |
45 |
Correct |
19 ms |
2904 KB |
ok |
46 |
Correct |
25 ms |
2392 KB |
ok |
47 |
Correct |
18 ms |
3416 KB |
ok |
48 |
Correct |
19 ms |
3028 KB |
ok |
49 |
Correct |
19 ms |
3028 KB |
ok |
50 |
Correct |
18 ms |
3032 KB |
ok |
51 |
Correct |
19 ms |
2904 KB |
ok |
52 |
Correct |
18 ms |
3536 KB |
ok |
53 |
Correct |
18 ms |
3536 KB |
ok |
54 |
Correct |
18 ms |
3536 KB |
ok |
55 |
Correct |
18 ms |
3536 KB |
ok |
56 |
Correct |
19 ms |
3792 KB |
ok |
57 |
Correct |
18 ms |
2904 KB |
ok |
58 |
Correct |
19 ms |
2964 KB |
ok |
59 |
Correct |
18 ms |
2904 KB |
ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
500 KB |
ok |
2 |
Correct |
0 ms |
344 KB |
ok |
3 |
Correct |
1 ms |
344 KB |
ok |
4 |
Correct |
0 ms |
344 KB |
ok |
5 |
Correct |
0 ms |
344 KB |
ok |
6 |
Correct |
0 ms |
344 KB |
ok |
7 |
Correct |
0 ms |
344 KB |
ok |
8 |
Correct |
1 ms |
344 KB |
ok |
9 |
Correct |
31 ms |
3412 KB |
ok |
10 |
Correct |
286 ms |
48408 KB |
ok |
11 |
Correct |
0 ms |
344 KB |
ok |
12 |
Correct |
1 ms |
344 KB |
ok |
13 |
Correct |
0 ms |
348 KB |
ok |
14 |
Correct |
0 ms |
344 KB |
ok |
15 |
Correct |
0 ms |
344 KB |
ok |
16 |
Correct |
0 ms |
344 KB |
ok |
17 |
Correct |
0 ms |
344 KB |
ok |
18 |
Correct |
0 ms |
344 KB |
ok |
19 |
Correct |
0 ms |
344 KB |
ok |
20 |
Correct |
0 ms |
344 KB |
ok |
21 |
Correct |
1 ms |
500 KB |
ok |
22 |
Correct |
0 ms |
344 KB |
ok |
23 |
Correct |
0 ms |
344 KB |
ok |
24 |
Correct |
0 ms |
544 KB |
ok |
25 |
Correct |
1 ms |
344 KB |
ok |
26 |
Correct |
0 ms |
344 KB |
ok |
27 |
Correct |
0 ms |
344 KB |
ok |
28 |
Correct |
0 ms |
344 KB |
ok |
29 |
Correct |
0 ms |
344 KB |
ok |
30 |
Correct |
1 ms |
344 KB |
ok |
31 |
Correct |
0 ms |
344 KB |
ok |
32 |
Correct |
0 ms |
344 KB |
ok |
33 |
Correct |
0 ms |
344 KB |
ok |
34 |
Correct |
0 ms |
344 KB |
ok |
35 |
Correct |
0 ms |
344 KB |
ok |
36 |
Correct |
0 ms |
344 KB |
ok |
37 |
Correct |
0 ms |
348 KB |
ok |
38 |
Correct |
1 ms |
348 KB |
ok |
39 |
Correct |
0 ms |
344 KB |
ok |
40 |
Correct |
1 ms |
344 KB |
ok |
41 |
Correct |
0 ms |
344 KB |
ok |
42 |
Correct |
0 ms |
344 KB |
ok |
43 |
Correct |
0 ms |
344 KB |
ok |
44 |
Correct |
0 ms |
344 KB |
ok |
45 |
Correct |
1 ms |
344 KB |
ok |
46 |
Correct |
1 ms |
348 KB |
ok |
47 |
Correct |
20 ms |
2648 KB |
ok |
48 |
Correct |
22 ms |
2772 KB |
ok |
49 |
Correct |
21 ms |
2664 KB |
ok |
50 |
Correct |
19 ms |
2904 KB |
ok |
51 |
Correct |
25 ms |
2392 KB |
ok |
52 |
Correct |
18 ms |
3416 KB |
ok |
53 |
Correct |
19 ms |
3028 KB |
ok |
54 |
Correct |
19 ms |
3028 KB |
ok |
55 |
Correct |
18 ms |
3032 KB |
ok |
56 |
Correct |
19 ms |
2904 KB |
ok |
57 |
Correct |
18 ms |
3536 KB |
ok |
58 |
Correct |
18 ms |
3536 KB |
ok |
59 |
Correct |
18 ms |
3536 KB |
ok |
60 |
Correct |
18 ms |
3536 KB |
ok |
61 |
Correct |
19 ms |
3792 KB |
ok |
62 |
Correct |
18 ms |
2904 KB |
ok |
63 |
Correct |
19 ms |
2964 KB |
ok |
64 |
Correct |
18 ms |
2904 KB |
ok |
65 |
Correct |
320 ms |
34184 KB |
ok |
66 |
Correct |
313 ms |
49852 KB |
ok |
67 |
Correct |
324 ms |
50064 KB |
ok |
68 |
Correct |
305 ms |
41040 KB |
ok |
69 |
Correct |
370 ms |
33360 KB |
ok |
70 |
Correct |
313 ms |
33048 KB |
ok |
71 |
Correct |
309 ms |
44880 KB |
ok |
72 |
Correct |
352 ms |
48036 KB |
ok |
73 |
Correct |
310 ms |
41104 KB |
ok |
74 |
Correct |
359 ms |
40672 KB |
ok |
75 |
Correct |
311 ms |
41276 KB |
ok |
76 |
Correct |
312 ms |
43896 KB |
ok |
77 |
Correct |
293 ms |
43956 KB |
ok |
78 |
Correct |
306 ms |
36304 KB |
ok |
79 |
Correct |
291 ms |
49352 KB |
ok |
80 |
Correct |
298 ms |
49804 KB |
ok |
81 |
Correct |
283 ms |
49604 KB |
ok |
82 |
Correct |
291 ms |
49132 KB |
ok |
83 |
Correct |
311 ms |
50320 KB |
ok |
84 |
Correct |
272 ms |
49556 KB |
ok |
85 |
Correct |
280 ms |
49356 KB |
ok |
86 |
Correct |
284 ms |
50012 KB |
ok |
87 |
Correct |
290 ms |
49808 KB |
ok |
88 |
Correct |
278 ms |
56696 KB |
ok |
89 |
Correct |
312 ms |
56840 KB |
ok |
90 |
Correct |
307 ms |
62376 KB |
ok |
91 |
Correct |
293 ms |
43392 KB |
ok |
92 |
Correct |
287 ms |
49872 KB |
ok |
93 |
Correct |
296 ms |
49052 KB |
ok |
94 |
Correct |
279 ms |
48840 KB |
ok |
95 |
Correct |
279 ms |
49348 KB |
ok |
96 |
Correct |
293 ms |
50572 KB |
ok |
97 |
Correct |
361 ms |
49296 KB |
ok |
98 |
Correct |
280 ms |
49676 KB |
ok |
99 |
Correct |
303 ms |
34016 KB |
ok |
100 |
Correct |
301 ms |
42832 KB |
ok |
101 |
Correct |
300 ms |
44200 KB |
ok |
102 |
Correct |
303 ms |
43280 KB |
ok |
103 |
Correct |
300 ms |
41492 KB |
ok |
104 |
Correct |
304 ms |
40980 KB |
ok |
105 |
Correct |
316 ms |
40528 KB |
ok |
106 |
Correct |
312 ms |
41288 KB |
ok |
107 |
Correct |
296 ms |
40532 KB |
ok |
108 |
Correct |
302 ms |
38332 KB |
ok |
109 |
Correct |
307 ms |
38532 KB |
ok |