Submission #367381

#TimeUsernameProblemLanguageResultExecution timeMemory
367381ijxjdjdQuality Of Living (IOI10_quality)C++14
80 / 100
5102 ms182640 KiB
using namespace std; #include <bits/stdc++.h> #include "quality.h" #define FR(i, N) for (int i = 0; i < int(N); i++) #define all(x) begin(x), end(x) int pref[3001][3001]; int rectangle(int R, int C, int H, int W, int Q[3001][3001]) { int low = 0; int high = R*C-1; vector<pair<int, int>> coords; FR(i, R){ FR(j, C){ coords.push_back({i, j}); } } auto comp = [&] (const auto& lhs, const auto& rhs) { return Q[lhs.first][lhs.second] < Q[rhs.first][rhs.second]; }; auto sum = [&] (int i, int j) { return pref[i][j] - (i >= H ? pref[i-H][j] : 0) - (j >= W ? pref[i][j-W] : 0) + (j >= W && i >= H ? pref[i-H][j-W] : 0); }; sort(all(coords), comp); int base = H*W/2; while (low < high) { int mid = (low + high)/2; FR(i, R) FR(j, C) pref[i][j] = 0; FR(i, mid+1) { pref[coords[i].first][coords[i].second]++; } FR(i, R) { FR(j, C) { pref[i][j] += (i > 0 ? pref[i-1][j] : 0) + (j > 0 ? pref[i][j-1] : 0) - (i > 0 && j > 0 ? pref[i-1][j-1] : 0); } } for (int i = H-1; i < R; i++) { for (int j = W-1; j < C; j++) { if (sum(i, j) > base) { high = mid; } } } if (high != mid) { low = mid+1; } } return high+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...