# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
685264 | smartmonky | 호화 벙커 (IZhO13_burrow) | C++14 | 1 ms | 212 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define int long long
using namespace std;
const int N = 2e5 + 5;
int v[1001][1001];
int n, m, k;
int ans;
bool check(int x){
vector < vector <int> > p(n + 1, vector <int> (m + 1, 0));
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
p[i][j] = (v[i][j] >= x) + p[i - 1][j];
}
}
ans = 0;
for(int i = 1; i <= n; i++){
deque <int> q;
for(int j = 1 ; j <= m; j++){
int ind = j;
while(!q.empty() && p[i][j] <= p[i][q.front()]){
ans = max(ans, p[i][q.front()] * (j - q.front()));
p[i][q.front()] = p[i][j];
ind = min(ind, q.front());
q.pop_front();
}
q.push_front(ind);
}
while(!q.empty()){
ans = max(((m + 1) - q.front()) * p[i][q.front()], ans);
q.pop_front();
}
}
return (ans >= k);
}
main(){
cin >> n >> m >> k;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
cin >> v[i][j];
}
}
int l = 1, r = 1e9, ar = 0;
while(r - l > 1){
int mid = (l + r) >> 1;
if(check(mid)){
l = mid;
ar = ans;
}else
r = mid;
}
check(l);
if(!check(l))
cout <<"0 0";
else
cout << l <<" " << ans;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |