답안 #81821

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
81821 2018-10-27T03:15:23 Z mra2322001 호화 벙커 (IZhO13_burrow) C++14
100 / 100
795 ms 54500 KB
#include <bits/stdc++.h>
#define f0(i, n) for(int i(0); i < (n); i++)
#define f1(i, n) for(int i(1); i <= n; i++)

using namespace std;
typedef long long ll;
const int N = 1002;

int n, k, a[N][N], m, l[N], r[N], b[N], cur = 0;
vector <int> v;

bool check(int x){
    f1(i, n) b[i] = 0;
    int res = 0;
    stack <int> s;
    f1(i, m){
        f1(j, n){
            if(a[i][j] >= x) b[j]++;
            else b[j] = 0;
        }
        f1(j, n){
            while(s.size() && b[s.top()] >= b[j]) s.pop();
            if(s.size()) l[j] = s.top() + 1;
            else l[j] = 1;
            s.push(j);
        }
        while(s.size()) s.pop();
        for(int j = n; j >= 1; j--){
            while(s.size() && b[s.top()] >= b[j]) s.pop();
            if(s.size()) r[j] = s.top() - 1;
            else r[j] = n;
            s.push(j);
        }
        f1(j, n){
            res = max(res, (r[j] - l[j] + 1)*b[j]);
        }
        while(s.size()) s.pop();
    }
    if(res >= k){
        cur = res;
        return 1;
    }
    return 0;
}

int main(){
    ios_base::sync_with_stdio(0);

    cin >> m >> n >> k;
    f1(i, m) f1(j, n) { cin >> a[i][j]; v.emplace_back(a[i][j]); }
    sort(v.begin(), v.end());

    v.erase(unique(v.begin(), v.end()), v.end());
    int l = 0, r = v.size() - 1, ans = 0;
    while(l <= r){
        int mid = (l + r)/2;
        if(check(v[mid])) l = mid + 1, ans = mid;
        else r = mid - 1;
    }
    cout << v[ans] << " " << cur;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 560 KB Output is correct
3 Correct 2 ms 560 KB Output is correct
4 Correct 2 ms 608 KB Output is correct
5 Correct 3 ms 608 KB Output is correct
6 Correct 2 ms 640 KB Output is correct
7 Correct 2 ms 640 KB Output is correct
8 Correct 7 ms 1048 KB Output is correct
9 Correct 12 ms 1796 KB Output is correct
10 Correct 30 ms 2316 KB Output is correct
11 Correct 46 ms 3168 KB Output is correct
12 Correct 22 ms 4212 KB Output is correct
13 Correct 36 ms 4212 KB Output is correct
14 Correct 74 ms 5380 KB Output is correct
15 Correct 81 ms 6012 KB Output is correct
16 Correct 133 ms 7108 KB Output is correct
17 Correct 66 ms 8196 KB Output is correct
18 Correct 271 ms 11856 KB Output is correct
19 Correct 273 ms 14504 KB Output is correct
20 Correct 579 ms 21384 KB Output is correct
21 Correct 620 ms 28352 KB Output is correct
22 Correct 795 ms 39348 KB Output is correct
23 Correct 784 ms 48800 KB Output is correct
24 Correct 393 ms 50488 KB Output is correct
25 Correct 353 ms 54500 KB Output is correct