Submission #75962

# Submission time Handle Problem Language Result Execution time Memory
75962 2018-09-11T16:56:33 Z Vardanyan Luxury burrow (IZhO13_burrow) C++14
0 / 100
2000 ms 1480 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
int t[N][4*N];
int a[N][N];
void build(int row,int v,int l,int r){
    if(l == r){
        t[row][v] = a[row][l];
        return;
    }
    int m = (l+r)/2;
    build(row,v*2,l,m);
    build(row,v*2+1,m+1,r);
    t[row][v] = min(t[row][v*2],t[row][v*2+1]);
}
int query(int row,int v,int s,int e,int l,int r){
    if(l>r) return 1000*1000*1000+5;
    if(s == l && e == r) return t[row][v];
    int m = (s+e)/2;
    return min(query(row,v*2,s,m,l,min(m,r)),query(row,v*2+1,m+1,e,max(l,m+1),r));
}
int main(){
    int n,m,k;
    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]);
        build(i,1,1,m);
    }
    int mxans = 0;
    int mxs = k;
    for(int i = 1;i<=n;i++){
        for(int j = 1;j<=m;j++){
            for(int jj = j;jj<=m;jj++){
                /*if(j == 1 && jj == m){
                    cout<<0<<endl;
                }*/
                int mnnow = 1000*1000*1000+5;
                bool f = false;
                for(int ii = i;ii<=n;ii++){
                    mnnow = min(mnnow,query(ii,1,1,m,j,jj));
                    /*if(mnnow<mxans){
                        f = true;
                        continue;
                    //    break;
                    }*/
                    int s = (jj-j+1)*(ii-i+1);
                    if(mnnow == mxans){
                        if(s>=mxs){
                            mxs = s;
                        }
                    }
                    if(mnnow>mxans){
                        if(s>=k){
                            mxs = s;
                            mxans = mnnow;
                        }
                    }
                }
                if(f) break;
            }
        }
    }
    cout<<mxans<<" "<<mxs<<endl;
    return 0;
}

Compilation message

burrow.cpp: In function 'int main()':
burrow.cpp:24:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d",&n,&m,&k);
     ~~~~~^~~~~~~~~~~~~~~~~~~
burrow.cpp:26:38: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         for(int j = 1;j<=m;j++) scanf("%d",&a[i][j]);
                                 ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 568 KB Output is correct
3 Correct 3 ms 672 KB Output is correct
4 Correct 6 ms 672 KB Output is correct
5 Correct 16 ms 732 KB Output is correct
6 Correct 54 ms 780 KB Output is correct
7 Correct 39 ms 780 KB Output is correct
8 Execution timed out 2061 ms 1480 KB Time limit exceeded
9 Halted 0 ms 0 KB -