Submission #820149

#TimeUsernameProblemLanguageResultExecution timeMemory
820149WLZQuality Of Living (IOI10_quality)C++17
100 / 100
2566 ms175584 KiB
#include "quality.h" #include <bits/stdc++.h> using namespace std; int R, C, H, W; int Q[3001][3001]; bool check(int k) { vector< vector<int> > pre(R + 1, vector<int>(C + 1, 0)); for (int i = 0; i < R; i++) for (int j = 0; j < C; j++) if (Q[i][j] <= k) pre[i + 1][j + 1] = 1; for (int i = 1; i <= R; i++) for (int j = 1; j <= C; j++) pre[i][j] += pre[i - 1][j] + pre[i][j - 1] - pre[i - 1][j - 1]; for (int i = H; i <= R; i++) { for (int j = W; j <= C; j++) { if (pre[i][j] - pre[i - H][j] - pre[i][j - W] + pre[i - H][j - W] >= (H * W + 1) / 2) return true; } } return false; } int rectangle(int _R, int _C, int _H, int _W, int _Q[3001][3001]) { R = _R, C = _C, H = _H, W = _W; for (int i = 0; i < R; i++) for (int j = 0; j < C; j++) Q[i][j] = _Q[i][j]; int lo = 1, hi = R * C; while (lo < hi) { //cerr << lo << endl; int mid = (lo + hi) / 2; if (check(mid)) hi = mid; else lo = mid + 1; } return lo; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...