Submission #714948

#TimeUsernameProblemLanguageResultExecution timeMemory
714948TheConverseEngineer3D Histogram (COCI20_histogram)C++17
20 / 110
23 ms1272 KiB
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for(int i = a; i < (b); ++i) #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() #define sqr(x) ((ll)(x))*(x) typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; #define MOD 1000000007 int N; int W[12][2005], H[12][2005]; int minH(int l, int r) { int i = __builtin_clz(1) - __builtin_clz(r-l+1); return min(H[i][l], H[i][r - (1<<i) + 1]); } int minW(int l, int r) { int i = __builtin_clz(1) - __builtin_clz(r-l+1); return min(W[i][l], W[i][r - (1<<i) + 1]); } int main() { cin.tie(0)->sync_with_stdio(0); cin >> N; FOR(i, 0, N) cin >> W[0][i] >> H[0][i]; for (int i = 1; i <= 11; ++i) { for (int j = 0; j + (1<<i) <= N; ++j) { W[i][j] = min(W[i-1][j], W[i-1][j + (1<<(i-1))]); H[i][j] = min(H[i-1][j], H[i-1][j + (1<<(i-1))]); } } ll mx = 0; FOR(i, 0, N) { FOR(j, i, N) { mx = max(mx, (ll)minH(i, j)*minW(i, j)*(j-i+1)); } } cout << mx; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...