이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 |
---|
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... |