# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
958100 | Hacv16 | Quality Of Living (IOI10_quality) | C++17 | 1 ms | 2392 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;
int rectangle(int n, int m, int h, int w, int q[3001][3001])
{
auto f = [&](int x)
{
vector<vector<int>> sums(n + 1, vector<int>(m + 1, 0));
for(int i = 1; i <= n; i++)
for(int j = 1; j <= m; j++)
sums[i][j] = sums[i - 1][j] + sums[i][j - 1] - sums[i - 1][j - 1] + (q[i - 1][j - 1] <= x);
for(int i = h; i <= n; i++)
{
for(int j = w; j <= m; j++)
{
int curSum = sums[i][j] - sums[i - h][j] - sums[i][j - w] + sums[i - h][j - w];
if(2 * curSum >= h * w) return true;
}
return false;
}
};
int l = 1, r = n * m;
while(l < r)
{
int mid = (l + r) >> 1;
if(f(mid)) r = mid;
else l = mid + 1;
}
return r;
}
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... |