█████████ ████ ███░░░░░███ ░░███ ███ ░░░ ██████ ███████ ██████ ██████ ░███ ███░░███ ███░░███ ███░░███ ███░░███ ░███ ░███ ░███░███ ░███ ░███████ ░███ ░███ ░░███ ███░███ ░███░███ ░███ ░███░░░ ░███ ░███ ░░█████████ ░░██████ ░░████████░░██████ ░░██████ ░░░░░░░░░ ░░░░░░ ░░░░░░░░ ░░░░░░ ░░░░░░

Envío 5843

Problema 0x50 - Rectángulo de máxima área dentro de un histograma enorme

  • Autor: nivalderramas
  • Fecha: 2022-03-10 20:44:45 UTC (Hace alrededor de 2 años)
Caso # Resultado Tiempo Memoria
#1
Error de compilación
                      main.c:1:10: fatal error: 'bits/stdc++.h' file not found
#include <bits/stdc++.h>
         ^~~~~~~~~~~~~~~
1 error generated.

                    
#2
Error de compilación
                      main.c:1:10: fatal error: 'bits/stdc++.h' file not found
#include <bits/stdc++.h>
         ^~~~~~~~~~~~~~~
1 error generated.

                    
#3
Error de compilación
                      main.c:1:10: fatal error: 'bits/stdc++.h' file not found
#include <bits/stdc++.h>
         ^~~~~~~~~~~~~~~
1 error generated.

                    
#4
Error de compilación
                      main.c:1:10: fatal error: 'bits/stdc++.h' file not found
#include <bits/stdc++.h>
         ^~~~~~~~~~~~~~~
1 error generated.

                    
#5
Error de compilación
                      main.c:1:10: fatal error: 'bits/stdc++.h' file not found
#include <bits/stdc++.h>
         ^~~~~~~~~~~~~~~
1 error generated.

                    
#6
Error de compilación
                      main.c:1:10: fatal error: 'bits/stdc++.h' file not found
#include <bits/stdc++.h>
         ^~~~~~~~~~~~~~~
1 error generated.

                    
#7
Error de compilación
                      main.c:1:10: fatal error: 'bits/stdc++.h' file not found
#include <bits/stdc++.h>
         ^~~~~~~~~~~~~~~
1 error generated.

                    
#8
Error de compilación
                      main.c:1:10: fatal error: 'bits/stdc++.h' file not found
#include <bits/stdc++.h>
         ^~~~~~~~~~~~~~~
1 error generated.

                    
#9
Error de compilación
                      main.c:1:10: fatal error: 'bits/stdc++.h' file not found
#include <bits/stdc++.h>
         ^~~~~~~~~~~~~~~
1 error generated.

                    
#10
Error de compilación
                      main.c:1:10: fatal error: 'bits/stdc++.h' file not found
#include <bits/stdc++.h>
         ^~~~~~~~~~~~~~~
1 error generated.

                    
#11
Error de compilación
                      main.c:1:10: fatal error: 'bits/stdc++.h' file not found
#include <bits/stdc++.h>
         ^~~~~~~~~~~~~~~
1 error generated.

                    
#12
Error de compilación
                      main.c:1:10: fatal error: 'bits/stdc++.h' file not found
#include <bits/stdc++.h>
         ^~~~~~~~~~~~~~~
1 error generated.

                    
#13
Error de compilación
                      main.c:1:10: fatal error: 'bits/stdc++.h' file not found
#include <bits/stdc++.h>
         ^~~~~~~~~~~~~~~
1 error generated.

                    
#14
Error de compilación
                      main.c:1:10: fatal error: 'bits/stdc++.h' file not found
#include <bits/stdc++.h>
         ^~~~~~~~~~~~~~~
1 error generated.

                    
#15
Error de compilación
                      main.c:1:10: fatal error: 'bits/stdc++.h' file not found
#include <bits/stdc++.h>
         ^~~~~~~~~~~~~~~
1 error generated.

                    
#16
Error de compilación
                      main.c:1:10: fatal error: 'bits/stdc++.h' file not found
#include <bits/stdc++.h>
         ^~~~~~~~~~~~~~~
1 error generated.

                    
#17
Error de compilación
                      main.c:1:10: fatal error: 'bits/stdc++.h' file not found
#include <bits/stdc++.h>
         ^~~~~~~~~~~~~~~
1 error generated.

                    
#18
Error de compilación
                      main.c:1:10: fatal error: 'bits/stdc++.h' file not found
#include <bits/stdc++.h>
         ^~~~~~~~~~~~~~~
1 error generated.

                    
#19
Error de compilación
                      main.c:1:10: fatal error: 'bits/stdc++.h' file not found
#include <bits/stdc++.h>
         ^~~~~~~~~~~~~~~
1 error generated.

                    
#20
Error de compilación
                      main.c:1:10: fatal error: 'bits/stdc++.h' file not found
#include <bits/stdc++.h>
         ^~~~~~~~~~~~~~~
1 error generated.

                    
#21
Error de compilación
                      main.c:1:10: fatal error: 'bits/stdc++.h' file not found
#include <bits/stdc++.h>
         ^~~~~~~~~~~~~~~
1 error generated.

                    
#22
Error de compilación
                      main.c:1:10: fatal error: 'bits/stdc++.h' file not found
#include <bits/stdc++.h>
         ^~~~~~~~~~~~~~~
1 error generated.

                    
#23
Error de compilación
                      main.c:1:10: fatal error: 'bits/stdc++.h' file not found
#include <bits/stdc++.h>
         ^~~~~~~~~~~~~~~
1 error generated.

                    
#24
Error de compilación
                      main.c:1:10: fatal error: 'bits/stdc++.h' file not found
#include <bits/stdc++.h>
         ^~~~~~~~~~~~~~~
1 error generated.

                    
#25
Error de compilación
                      main.c:1:10: fatal error: 'bits/stdc++.h' file not found
#include <bits/stdc++.h>
         ^~~~~~~~~~~~~~~
1 error generated.

                    
#26
Error de compilación
                      main.c:1:10: fatal error: 'bits/stdc++.h' file not found
#include <bits/stdc++.h>
         ^~~~~~~~~~~~~~~
1 error generated.

                    
#27
Error de compilación
                      main.c:1:10: fatal error: 'bits/stdc++.h' file not found
#include <bits/stdc++.h>
         ^~~~~~~~~~~~~~~
1 error generated.

                    
#28
Error de compilación
                      main.c:1:10: fatal error: 'bits/stdc++.h' file not found
#include <bits/stdc++.h>
         ^~~~~~~~~~~~~~~
1 error generated.

                    
#29
Error de compilación
                      main.c:1:10: fatal error: 'bits/stdc++.h' file not found
#include <bits/stdc++.h>
         ^~~~~~~~~~~~~~~
1 error generated.

                    
Puntos totales: 0 / 100

Código

#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<n;i++)
#define pb push_back
#define ff first
#define ss second
#include <assert.h>
#define ii pair<int,int>
#define vii vector<ii>
#define lli long long int
#define vi vector<lli>
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
ostream& operator<<(ostream& os, const vector<lli> &v){
    for(auto const &i: v){
        os<<i<<" ";
    }
    os<<endl;
    return os;
}
const lli mod=(1e9)+7;
const int N = 1e4+1;
int main(){
    fast_io;
    int n;cin>>n;
    vi nums;
    lli tmp;
    for(int i = 0; i < n; i++){
        cin>>tmp;
        nums.pb(tmp);
    }
    stack<lli> st;
    vi der(n,0);
    for(int i = n-1; i>=0; i--){
        while(st.size() > 0 && nums[st.top()] >= nums[i]){
            st.pop();
        }
        der[i] = (st.size() ? st.top() : i);
        st.push(i);
        
    }
    cout<<der<<endl;
    while(st.size())st.pop();
    lli ans = 0;
    vi lef(n,0);
    for(int i = 0; i<n; i++){
        while(st.size() > 0 && nums[st.top()] >= nums[i]){
            st.pop();
        }
        lef[i] = (st.size() ? st.top() : i);
        st.push(i);
        
    }
    cout<<lef<<endl;
    for(int i = 0; i < n; i++){
        lli d = abs(i-der[i]+1);
        lli iz = abs(i-lef[i]+1);
        ans = max(ans,nums[i]*max(d,iz));
    }
    cout<<ans<<endl;
    return 0;
}