# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
303053 | iliccmarko | Quality Of Living (IOI10_quality) | C++14 | 4692 ms | 109868 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 <bits/stdc++.h>
#include<quality.h>
using namespace std;
#define ll long long
#define endl "\n"
using namespace std;
int rectangle(int r, int c, int h, int w, int q[3001][3001])
{
int l = 1;
int R = r*c;
int ans;
int prefix[r][c];
while(l<=R)
{
int mid = (l+R)/2;
for(int i = 0;i<r;i++)
{
for(int j = 0;j<c;j++)
{
if(j==0)
{
if(q[i][j]<mid)
prefix[i][j] = -1;
else if(q[i][j]==mid)
prefix[i][j] = 0;
else
prefix[i][j] = 1;
}
else
{
if(q[i][j]<mid)
prefix[i][j] = -1;
else if(q[i][j]==mid)
prefix[i][j] = 0;
else
prefix[i][j] = 1;
prefix[i][j] += prefix[i][j-1];
}
}
}
int s, e;
s = e = 0;
int sum = 0;
for(int i = w-1;i<c;i++)
{
sum = 0;
for(int j = 0;j<h;j++)
{
if(i==w-1)
{
sum+=prefix[j][w-1];
}
else
{
sum+=prefix[j][i] - prefix[j][i-w];
}
}
if(sum<0)
{
s++;
break;
}
else if(sum==0)
{
e++;
}
for(int j = h;j<r;j++)
{
if(i==w-1)
{
sum-=prefix[j-h][w-1];
sum+=prefix[j][w-1];
}
else
{
sum-=prefix[j-h][i] - prefix[j-h][i-w];
sum+=prefix[j][i] - prefix[j][i-w];
}
if(sum<0)
{
s++;
break;
}
else if(sum==0)
{
e++;
}
}
if(s!=0) break;
}
if(s)
{
R = mid - 1;
}
else if(e)
{
ans = mid;
break;
}
else
{
l = mid + 1;
}
}
return ans;
}
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... |