답안 #13057

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
13057 2015-01-28T02:44:08 Z gs14004 호화 벙커 (IZhO13_burrow) C++14
100 / 100
513 ms 9104 KB
#include <cstdio>
#include <vector>
using namespace std;

int n,m,k;
int a[1005][1005];
int t[1005][1005];

int eval(){
    vector<int> v;
    int ret = 0;
    for (int i=1; i<=n; i++) {
        for (int j=1; j<=m; j++) {
            while (!v.empty() && t[i][v.back()] > t[i][j]) {
                int wid = 0;
                int bk = v.back();
                v.pop_back();
                if(v.empty()){
                    wid = j-1;
                }
                else{
                    wid = j - v.back() - 1;
                }
                ret = max(ret,t[i][bk] * wid);
            }
            v.push_back(j);
        }
        while (!v.empty()) {
            int wid = 0;
            int bk = v.back();
            v.pop_back();
            if(v.empty()){
                wid = m;
            }
            else{
                wid = m - v.back();
            }
            ret = max(ret,t[i][bk] * wid);
        }
    }
    return ret;
}

int main(){
    scanf("%d %d %d",&n,&m,&k);
    for (int i=1; i<=n; i++) {
        for (int j=1; j<=m; j++) {
            scanf("%d",&a[i][j]);
        }
    }
    int s = 0, e = 1e9;
    while (s != e) {
        int mi = (s+e+1)/2;
        for (int i=1; i<=n; i++) {
            for (int j=1; j<=m; j++) {
                t[i][j] = (a[i][j] >= mi ? (t[i-1][j] + 1) : 0);
            }
        }
        if(eval() >= k) s = mi;
        else e = mi-1;
    }
    for (int i=1; i<=n; i++) {
        for (int j=1; j<=m; j++) {
            t[i][j] = (a[i][j] >= s ? (t[i-1][j] + 1) : 0);
        }
    }
    printf("%d %d\n",s,eval());
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 9104 KB Output is correct
2 Correct 0 ms 9104 KB Output is correct
3 Correct 0 ms 9104 KB Output is correct
4 Correct 0 ms 9104 KB Output is correct
5 Correct 0 ms 9104 KB Output is correct
6 Correct 1 ms 9104 KB Output is correct
7 Correct 0 ms 9104 KB Output is correct
8 Correct 5 ms 9104 KB Output is correct
9 Correct 9 ms 9104 KB Output is correct
10 Correct 24 ms 9104 KB Output is correct
11 Correct 40 ms 9104 KB Output is correct
12 Correct 22 ms 9104 KB Output is correct
13 Correct 32 ms 9104 KB Output is correct
14 Correct 67 ms 9104 KB Output is correct
15 Correct 63 ms 9104 KB Output is correct
16 Correct 71 ms 9104 KB Output is correct
17 Correct 74 ms 9104 KB Output is correct
18 Correct 171 ms 9104 KB Output is correct
19 Correct 191 ms 9104 KB Output is correct
20 Correct 353 ms 9104 KB Output is correct
21 Correct 348 ms 9104 KB Output is correct
22 Correct 513 ms 9104 KB Output is correct
23 Correct 500 ms 9104 KB Output is correct
24 Correct 304 ms 9104 KB Output is correct
25 Correct 361 ms 9104 KB Output is correct