Submission #440310

#TimeUsernameProblemLanguageResultExecution timeMemory
440310nguot3D Histogram (COCI20_histogram)C++14
20 / 110
2573 ms11612 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;}) mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int rnd(int l,int r){return l+rng()%(r-l+1);} #define fasty ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0); #define fori(x,a,b) for(int x=a;x<=b;x++) #define ford(x,a,b) for(int x=a;x>=b;x--) #define forv(a,b) for(auto&a:b) #define fi first #define se second #define pb push_back #define ii pair<int,int> #define mt make_tuple #define all(a) a.begin(),a.end() #define reset(f,x) memset(f,x,sizeof(f)) #define getbit(x,i) ((x>>i)&1) #define batbit(x,i) (x|(1ll<<i)) #define tatbit(x,i) (x&~(1<<i)) #define gg exit(0); const int N = 2e5 + 10; int l[N],r[N],sb[4*N],sa[4*N],a[N],b[N],n; void build(int x,int l,int r) { if(l==r) { sa[x] = a[l],sb[x] = b[l]; return; } int mid = (l+r)/2; build(2*x,l,mid);build(2*x+1,mid+1,r); sa[x] = min(sa[2*x],sa[2*x+1]); sb[x] = min(sb[2*x],sb[2*x+1]); } int geta(int x,int l,int r,int u,int v) { if(l>v||r<u) return 1000010; if(l>=u&&r<=v) return sa[x]; int mid = (l+r)/2; return min(geta(2*x,l,mid,u,v),geta(2*x+1,mid+1,r,u,v)); } int getb(int x,int l,int r,int u,int v) { if(l>v||r<u) return 1000010; if(l>=u&&r<=v) return sb[x]; int mid = (l+r)/2; return min(getb(2*x,l,mid,u,v),getb(2*x+1,mid+1,r,u,v)); } main() { //freopen("task.inp","r",stdin); fasty; cin>>n; fori(i,1,n) cin>>a[i]>>b[i]; build(1,1,n); int kq = 0; fori(i,1,n) fori(j,i,n) { int H = geta(1,1,n,i,j); int L = getb(1,1,n,i,j); kq=max(kq,(j-i+1)*H*L); } cout<<kq; }

Compilation message (stderr)

histogram.cpp:55:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   55 | main()
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...