Submission #777425

#TimeUsernameProblemLanguageResultExecution timeMemory
777425PetrixQuality Of Living (IOI10_quality)C++17
0 / 100
34 ms106156 KiB
#include "grader.h" #include <bits/stdc++.h> using namespace std; int rectangle(int r,int c,int h,int w,int q[3001][3001]){ int sm[3001][3001],bi[3001][3001],v[3001][3001],st,dr,mij,i,j,ans; for(i=1;i<=r;i++){ for(j=1;j<=c;j++){ v[i][j]=q[i-1][j-1]; } } st=0;dr=r*c;ans=r*c; while(st<dr){ int s,b; mij=(st+dr)/2; bool adv=0; for(i=1;i<=r;i++){ s=0;b=0; for(j=1;j<=c;j++){ sm[i][j]=sm[i-1][j]+s; if(v[i][j]<mij){ sm[i][j]++;s++; } bi[i][j]=bi[i-1][j]+b; if(v[i][j]>mij){ bi[i][j]++;b++; } } } for(i=1;i<=r-h+1;i++){ for(j=0;j<c-w+1;j++){ s=sm[i+h-1][j+w-1]-sm[i+h-1][j-1]-sm[i-1][j+w-1]+sm[i-1][j-1]; b=bi[i+h-1][j+w-1]-bi[i+h-1][j-1]-bi[i-1][j+w-1]+bi[i-1][j-1]; int n=r*c; if(s==b && s<=n/2 && n<=n/2) ans=min(ans,mij); if(s>=b) adv=1; } } if(adv==0) st=mij+1; else dr=mij-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...