Submission #440310

# Submission time Handle Problem Language Result Execution time Memory
440310 2021-07-02T02:44:32 Z nguot 3D Histogram (COCI20_histogram) C++14
20 / 110
2500 ms 11612 KB
#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

histogram.cpp:55:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   55 | main()
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 430 ms 416 KB Output is correct
2 Correct 544 ms 420 KB Output is correct
3 Correct 473 ms 424 KB Output is correct
4 Correct 516 ms 420 KB Output is correct
5 Correct 523 ms 420 KB Output is correct
6 Correct 493 ms 416 KB Output is correct
7 Correct 438 ms 416 KB Output is correct
8 Correct 496 ms 420 KB Output is correct
9 Correct 515 ms 332 KB Output is correct
10 Correct 483 ms 420 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 522 ms 416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 430 ms 416 KB Output is correct
2 Correct 544 ms 420 KB Output is correct
3 Correct 473 ms 424 KB Output is correct
4 Correct 516 ms 420 KB Output is correct
5 Correct 523 ms 420 KB Output is correct
6 Correct 493 ms 416 KB Output is correct
7 Correct 438 ms 416 KB Output is correct
8 Correct 496 ms 420 KB Output is correct
9 Correct 515 ms 332 KB Output is correct
10 Correct 483 ms 420 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 522 ms 416 KB Output is correct
13 Execution timed out 2573 ms 11612 KB Time limit exceeded
14 Halted 0 ms 0 KB -