Submission #406650

#TimeUsernameProblemLanguageResultExecution timeMemory
406650sobaQuality Of Living (IOI10_quality)C++14
0 / 100
1 ms332 KiB
#include <bits/stdc++.h> #include "quality.h" using namespace std; int rectangle(int R, int C, int H, int W, int Q[3001][3001]) { int l=1 , r= 3000*3000 , m , ans=r ; int arr[R+1][C+1]={0}; int x; bool flag; while(l<=r) { m=(l+r)>>1; memset(arr , 0 , sizeof arr); for(int i = 0 ; i < R ; i++) { for(int j = 0 ; j < C ;j++) { if(i==0||j==0) { arr[i][j]=0; } arr[i+1][j+1]=0; if(Q[i][j]<=m) { arr[i+1][j+1]=1; } } } for(int i = 1 ; i <= R ; i++) { for(int j = 1 ; j <=C ; j++) { arr[i][j]+=arr[i][j-1]; } } for(int i = 1 ; i <= R ; i++) { for(int j = 1 ; j <=C ; j++) { arr[i][j]+=arr[i-1][j]; } } flag=false; // cout << "checking mid = " << m << ":-\n"; for(int i = H ; i <=R ; i++) { for(int j = W ; j<=C ; j++) { // cout << "in " << i << " " << j << " = " ; x=arr[i][j]+arr[i-H][j-W]-arr[i-H][W]-arr[i][j-W]; // cout << x << "\n"; if(x>=(H*W)-x) { flag=true; break; } } if(flag) break; } if(flag) { ans=m; r=m-1; } else { l=m+1; } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...