Submission #511038

# Submission time Handle Problem Language Result Execution time Memory
511038 2022-01-15T04:47:31 Z tabr Quality Of Living (IOI10_quality) C++17
0 / 100
1 ms 424 KB
#include <bits/stdc++.h>
using namespace std;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int rectangle(int r, int c, int h, int w, int q[3001][3001]) {
    int low = 0;
    int high = r * c;
    while (high - low > 1) {
        int mid = (high + low) / 2;
        int ok = 0;
        vector<vector<int>> pref(r + 1, vector<int>(c + 1));
        for (int i = 0; i < r; i++) {
            for (int j = 0; j < c; j++) {
                pref[i + 1][j + 1] = pref[i + 1][j] + pref[i][j + 1] - pref[i][j] + (q[i][j] <= mid);
            }
        }
        for (int i = 0; i <= r - h; i++) {
            for (int j = 0; j <= c - w; j++) {
                if (pref[i + h][j + w] - pref[i][j + 1] - pref[i + h][j] + pref[i][j] > h * w / 2) {
                    ok = 1;
                }
            }
        }
        if (ok) {
            high = mid;
        } else {
            low = mid;
        }
    }
    return high;
}

#ifdef tabr
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int q[3001][3001];
    int r, c, h, w;
    cin >> r >> c >> h >> w;
    for (int i = 0; i < r; i++) {
        for (int j = 0; j < c; j++) {
            cin >> q[i][j];
        }
    }
    debug(rectangle(r, c, h, w, q));
    return 0;
}
#endif
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 424 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 424 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 424 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 424 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 424 KB Output isn't correct
2 Halted 0 ms 0 KB -