Submission #906123

#TimeUsernameProblemLanguageResultExecution timeMemory
906123JakobZorzQuality Of Living (IOI10_quality)C++17
80 / 100
5053 ms70860 KiB
#include"quality.h" #include<iostream> #include<vector> using namespace std; int w2,h2,w,h; int mat[3000][3000]; bool check(int val){ vector<int>cols(w2); for(int y=0;y<=h2-h;y++){ int low=0; for(int x2=0;x2<w-1;x2++) for(int y2=y;y2<y+h;y2++) low+=(mat[x2][y2]<=val); if(y==0){ for(int x=0;x<w2;x++) for(int y2=0;y2<h;y2++) cols[x]+=(mat[x][y2]<=val); }else{ for(int x=0;x<w2;x++){ cols[x]-=(mat[x][y-1]<=val); cols[x]+=(mat[x][y+h-1]<=val); } } for(int x=0;x<=w2-w;x++){ if(x) low-=cols[x-1]; low+=cols[x+w-1]; if(low>=(w*h+1)/2){ //cout<<val<<" "<<low<<" "<<(w*h+1)/2<<" false\n"; return true; } } } //cout<<val<<" true\n"; return false; } int rectangle(int R,int C,int H,int W,int Q[3001][3001]){ w2=R; h2=C; w=H; h=W; for(int x=0;x<w2;x++) for(int y=0;y<h2;y++) mat[x][y]=Q[x][y]; int bl=0,br=w2*h2; while(bl<br-1){ int mid=(bl+br)/2; if(check(mid)) br=mid; else bl=mid; } return br; }
#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...