# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
659320 | stevancv | Quality Of Living (IOI10_quality) | C++14 | 2271 ms | 175956 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"
#define ll long long
#define ld long double
#define sp ' '
#define en '\n'
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
using namespace std;
const int N = 3e3 + 2;
const int inf = 2e9;
int rectangle(int n, int m, int h, int w, int q[3001][3001]) {
vector<vector<int>> a(n + 1, vector<int>(m + 1));
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
a[i][j] = q[i - 1][j - 1];
}
}
auto Can = [&] (int x) {
vector<vector<int>> p(n + 1, vector<int>(m + 1, 0));
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (a[i][j] > x) p[i][j] = -1;
else if (a[i][j] < x) p[i][j] = 1;
p[i][j] += p[i - 1][j] + p[i][j - 1] - p[i - 1][j - 1];
}
}
for (int i = h; i <= n; i++) {
for (int j = w; j <= m; j++) {
if (p[i][j] - p[i - h][j] - p[i][j - w] + p[i - h][j - w] >= 0) return true;
}
}
return false;
};
int l = 1, r = n * m, ans = n * m;
while (l <= r) {
int mid = l + r >> 1;
if (Can(mid)) {
r = mid - 1;
ans = mid;
}
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... |