Submission #83712

#TimeUsernameProblemLanguageResultExecution timeMemory
83712mra2322001Luxury burrow (IZhO13_burrow)C++14
0 / 100
704 ms1840 KiB
#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 = 402;

int m, n, a[N][N], k, ma[N], now = 0;
int res = 0;

int calc(int k1, int k2, int cur){
    f1(i, n){
        int j = i;
        for(j; j <= n; j++){
            if(ma[j] >= cur) continue;
            else break;
        }
        --j;
        res = max(res, (k2 - k1 + 1)*(j - i + 1));
        i = j + 1;
    }
    return res;
}

bool check(int cur){
    res = 0;
    f1(i, m){
        f1(j, n) ma[j] = 1e9 + 100;
        for(int j = i; j <= m; j++){
            for(int x = 1; x <= n; x++){
                ma[x] = min(ma[x], a[j][x]);
            }
            res = max(res, calc(i, j, cur));
        }
    }
    if(res >= k) now = res;
    return res >= k;
}

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

    cin >> m >> n >> k;
    f1(i, m) f1(j, n) cin >> a[i][j];

    int l = 1, r = 1e9 + 2, ans = 1;
    while(l <= r){
        int mid = (l + r)/2;
        if(check(mid)) l = mid + 1, ans = mid;
        else r = mid - 1;
    }
    cout << ans << " " << now;
}

Compilation message (stderr)

burrow.cpp: In function 'int calc(int, int, int)':
burrow.cpp:15:14: warning: statement has no effect [-Wunused-value]
         for(j; j <= n; j++){
              ^
#Verdict Execution timeMemoryGrader output
Fetching results...