# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
388747 | Pichon5 | Quality Of Living (IOI10_quality) | C++17 | 2450 ms | 140244 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "quality.h"
#include <bits/stdc++.h>
#define vi vector<vi>
#define ll long long int
#define pb push_back
using namespace std;
int rectangle(int R, int C, int H, int W, int Q[3001][3001]) {
//R rows
//C columns
// H de hight
//W de weihght
int M[3001][3001];
int b=1,e=C*R;
int res;
while(b<=e){
int i=(b+e)/2;
for(int j=0;j<R;j++){
for(int k=0;k<C;k++){
M[j][k]=0;
if(Q[j][k]>i)M[j][k]=1;
if(Q[j][k]<i)M[j][k]=-1;
}
}
for(int j=0;j<R;j++){
for(int k=0;k<C;k++){
if(j)M[j][k]+=M[j-1][k];
if(k)M[j][k]+=M[j][k-1];
if(j>0 && k>0)M[j][k]-=M[j-1][k-1];
}
}
bool ok=false;
for(int j=0;j+H<=R;j++){
for(int k=0;k+W<=C;k++){
int sum=M[j+H-1][k+W-1];
if(j)sum-=M[j-1][k+W-1];
if(k)sum-=M[j+H-1][k-1];
if(j>0 && k>0)sum+=M[j-1][k-1];
if(sum<=0)ok=1;
}
}
if(ok){
res=i;
e=i-1;
}else{
b=i+1;
}
}
return res;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |