#include<bits/stdc++.h>
using namespace std;
#define ll long long
int biggest_stadium(int n, vector<vector<int>> arr){
vector<vector<int>> c(n, vector<int>(n));
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
if(arr[i][j] == 1) c[i][j] = 0;
else if(i == 0) c[i][j] = 1;
else c[i][j] = 1 + c[i - 1][j];
}
}
int ans = 0;
for(int kk = 0; kk < n; kk++){
vector<int> curr = c[kk];
stack<int> sl, sr;
vector<int> l(n), r(n);
for(int i = 0; i < n; i++){
while(sl.size() && curr[i] <= curr[sl.top()]){
sl.pop();
}
l[i] = (sl.size() ? 0 : sl.top() + 1);
sl.push(i);
}
for(int i = n - 1; i >= 0; i--){
while(sr.size() && curr[i] <= curr[sr.top()]){
sr.pop();
}
r[i] = (sr.size() ? n - 1 : sr.top() - 1);
sr.push(i);
}
for(int i = 0; i < n; i++){
ans = max(ans, (r[i] - l[i] + 1) * curr[i]);
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |