Submission #448153

#TimeUsernameProblemLanguageResultExecution timeMemory
448153jk4103D Histogram (COCI20_histogram)C++17
20 / 110
600 ms460 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int INF=1e9; int N; ll Ans; int Tree_A[1<<12],Tree_B[1<<12]; int update(int *tree,int s,int e,int idx,int v,int n){ if (idx<s||e<idx) return tree[n]; if (s==e) return tree[n]=v; int m=(s+e)>>1; return tree[n]=min(update(tree,s,m,idx,v,n<<1),update(tree,m+1,e,idx,v,n<<1|1)); } int query(int *tree,int s,int e,int l,int r,int n){ if (e<l||r<s) return INF; if (l<=s&&e<=r) return tree[n]; int m=(s+e)>>1; return min(query(tree,s,m,l,r,n<<1),query(tree,m+1,e,l,r,n<<1|1)); } int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>N; for (int i=1; i<=N; i++){ int a,b; cin>>a>>b; update(Tree_A,1,N,i,a,1); update(Tree_B,1,N,i,b,1); } for (int i=1; i<=N; i++){ for (int j=i; j<=N; j++) Ans=max(Ans,(ll)(j-i+1)*query(Tree_A,1,N,i,j,1)*query(Tree_B,1,N,i,j,1)); } cout<<Ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...