Submission #925497

#TimeUsernameProblemLanguageResultExecution timeMemory
925497VMaksimoski008Quality Of Living (IOI10_quality)C++14
0 / 100
1 ms2392 KiB
#include <bits/stdc++.h> #include "quality.h" using namespace std; using ll = long long; int pref[3005][3005]; int rectangle(int n, int m, int r, int c, int q[3001][3001]) { int lp=0, rp=1e9; int ans = 0; int mat[n+1][m+1]; for(int i=1; i<=n; i++) for(int j=1; j<=m; j++) mat[i][j] = q[i-1][j-1]; while(lp <= rp) { int mid = (lp + rp) / 2; bool ok = 0; for(int i=1; i<=n; i++) for(int j=1; j<=m; j++) pref[i][j] = (mat[i][j] >= mid) + pref[i][j-1] + pref[i-1][j] - pref[i-1][j-1]; for(int i=1; i+r-1<=n; i++) { if(ok) break; for(int j=1; j+c-1<=m; j++) { if(ok) break; ll res = pref[i+r-1][j+c-1] - pref[i-1][j+c-1] - pref[i+r-1][j-1] + pref[i-1][j-1]; if(2 * res >= r * c) ok = 1; } } if(ok) ans = mid, lp = mid + 1; else rp = 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...