제출 #1249092

#제출 시각아이디문제언어결과실행 시간메모리
1249092basa삶의 질 (IOI10_quality)C++20
100 / 100
1555 ms71000 KiB
#include "bits/stdc++.h" #include "quality.h" using namespace std; int pref[3005][3005]; bool check(int m, int r, int c, int h, int w, int q[3001][3001]){ memset(pref, 0, sizeof pref); for(int i = 1; i <= r; i++){ for(int j = 1; j <= c; j++){ pref[i][j] = pref[i - 1][j] + pref[i][j - 1] - pref[i - 1][j - 1]; if(q[i - 1][j - 1] > m) pref[i][j]++; } } bool valid = 0; for(int i = 1; i <= r - h + 1; i++){ for(int j = 1; j <= c - w + 1; j++){ int br = i + h - 1, bc = j + w - 1; if((pref[br][bc] - pref[i - 1][bc] - pref[br][j - 1] + pref[i - 1][j - 1]) <= (h * w) / 2) valid = 1; } } if(valid) return 1; return 0; } int rectangle(int n, int m, int h, int w, int q[3001][3001]){ int l = 1, r = n * m; while(l <= r){ int mid = (l + r) / 2; if(check(mid, n, m, h, w, q)) r = mid - 1; else l = mid + 1; } return r + 1; }
#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...