Submission #388288

#TimeUsernameProblemLanguageResultExecution timeMemory
388288ritul_kr_singhLuxury burrow (IZhO13_burrow)C++17
100 / 100
399 ms8260 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define sp << ' ' << #define nl << '\n' int n, m, k, g[1001][1001], a[1002]; int maxArea(){ int res = 0; vector<int> st = {0}; for(int j=1; j<=m+1; ++j){ while(!st.empty() and a[st.back()] > a[j]){ int y = a[st.back()]; st.pop_back(); res = max(res, (j-st.back()-1)*y); } st.push_back(j); } return res; } int best(int x){ fill(a, a+m+2, 0LL); int res = 0; for(int i=1; i<=n; ++i){ for(int j=1; j<=m; ++j) a[j] += g[i][j] >= x ? 1 : -a[j]; res = max(res, maxArea()); } return res; } signed main(){ cin.tie(0)->sync_with_stdio(0); cin >> n >> m >> k; for(int i=1; i<=n; ++i) for(int j=1; j<=m; ++j) cin >> g[i][j]; int x = 0; for(int y=1<<30; y; y/=2) if(best(x+y)>=k) x += y; cout << x sp best(x); }
#Verdict Execution timeMemoryGrader output
Fetching results...