Submission #861845

#TimeUsernameProblemLanguageResultExecution timeMemory
861845sleepntsheepQuality Of Living (IOI10_quality)C++17
100 / 100
1453 ms178712 KiB
#include <cstdio> #include <cstring> #include <cassert> #include <string> #include <deque> #include <vector> #include <map> #include <queue> #include <algorithm> #include <iostream> #include <utility> using namespace std; using ll=long long; #define ALL(x) x.begin(), x.end() #define N 3086 int n, m, h, w, a[N][N], p[N][N]; int ok(int y) { for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) p[i][j] = (a[i][j] <= y) + p[i-1][j] + p[i][j-1] - p[i-1][j-1]; for (int i = 1; i + h - 1 <= n; ++i) for (int j = 1; j + w - 1 <= m; ++j) if (p[i+h-1][j+w-1] - p[i-1][j+w-1] - p[i+h-1][j-1] + p[i-1][j-1] > (h*w-1)/2) return 1; return 0; } int rectangle(int n, int m, int h, int w, int q[3001][3001]) { ::n=n,::m=m,::h=h,::w=w; for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) a[i][j] = q[i-1][j-1]; int l = 0, r = 1e9; while (l <= r) { int y = (l+r)/2; ok(y) ? r = y - 1 : l = y + 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...