Submission #204146

#TimeUsernameProblemLanguageResultExecution timeMemory
204146KalamLuxury burrow (IZhO13_burrow)C++11
100 / 100
587 ms18568 KiB
// KALAM
# include<bits/stdc++.h>

using namespace std;

const int N = 1000 + 77;
int n , m , k , a[N][N] , b[N][N] , c[N] , L[N] , R[N];
inline int Solve() {
   int res = 0;
   for(int i = 1;i <= m;++ i) {
      L[i] = i - 1;
      while(c[L[i]] >= c[i] && L[i] > 0)
         L[i] = L[L[i]];
   }
   for(int i = m;i > 0;-- i) {
      R[i] = i + 1;
      while(c[R[i]] >= c[i] && R[i] <= m)
         R[i] = R[R[i]];
      res = max(res , (R[i] - L[i] - 1) * c[i]);
   }
   return res;
}
inline int Check(int t) {
   int res = 0;
   for(int i = 1;i <= n;++ i) {
      for(int j = 1;j <= m;++ j)
         b[i][j] = (a[i][j] >= t ? 1 + b[i - 1][j] : 0);
      for(int j = 1;j <= m;++ j)
         c[j] = b[i][j];
      res = max(res , Solve());
   }
   return res;
}
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 le = 1 , ri = 1000000001;
   while(ri - le > 1) {
      int mid = ((le + ri) >> 1);
      if(Check(mid) >= k)
         le = mid;
      else
         ri = mid;
   }
   printf("%d %d\n" , le , Check(le));
   return 0;
}

Compilation message (stderr)

burrow.cpp: In function 'int main()':
burrow.cpp:35:9: 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:38:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
          scanf("%d" , & a[i][j]);
          ~~~~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...