Submission #512647

#TimeUsernameProblemLanguageResultExecution timeMemory
512647algorithm16Quality Of Living (IOI10_quality)C++14
0 / 100
1 ms460 KiB
#include "quality.h" int sum[3005][3005]; int get_sum(int x1,int y1,int x2,int y2) { int ret=sum[x2][y2]; if(x1) ret-=sum[x1-1][y2]; if(y1) ret-=sum[x2][y1-1]; if(x1 && y1) ret+=sum[x1-1][y1-1]; return ret; } int rectangle(int R, int C, int H, int W, int Q[3001][3001]) { int r=R,c=C,h=H,w=W; int lo=1,hi=r*c; while(lo<hi) { int mid=(lo+hi)/2; int s=0,cnt=0; for(int i=0;i<r;i++) { for(int j=0;j<c;j++) { if(Q[i][j]<=mid) s+=1; else s-=1; sum[i][j]=s; if(i) sum[i][j]+=sum[i-1][j]; } } for(int i=0;i+h-1<r;i++) { for(int j=0;j+w-1<c;j++) { if(get_sum(i,j,i+h-1,j+w-1)>0) cnt+=1; } } if(cnt) hi=mid; else lo=mid+1; } return lo; }
#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...