Submission #998231

#TimeUsernameProblemLanguageResultExecution timeMemory
998231rahidilbayramliQuality Of Living (IOI10_quality)C++17
100 / 100
1263 ms105708 KiB
#include<bits/stdc++.h> #include "quality.h" #define ll long long #define ld long double #define vl vector<ll> #define vi vector<int> #define pii pair<int, int> #define pll pair<ll, ll> #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() #define f first #define s second #define pb push_back #define p_b pop_back using namespace std; int rectangle(int R, int C, int H, int W, int Q[3001][3001]) { int l = 1, r = R * C, ans = R * C; while(l <= r) { int grid[3001][3001]; int mid = (l + r) / 2, maxx = 0; for(int i = 0; i < R; i++) { for(int j = 0; j < C; j++) { int sum = 0; grid[i][j] = (Q[i][j] <= mid); if(i) grid[i][j] += grid[i-1][j]; if(j) grid[i][j] += grid[i][j-1]; if(i && j) grid[i][j] -= grid[i-1][j-1]; sum = grid[i][j]; if(i - H >= 0) sum -= grid[i-H][j]; if(j - W >= 0) sum -= grid[i][j-W]; if(i - H >= 0 && j - W >= 0) sum += grid[i-H][j-W]; maxx = max(maxx, sum); } } if(maxx > H * W / 2) { ans = min(ans, mid); r = mid - 1; } else l = mid + 1; } return ans; }
#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...