• 《洛谷P2659 美丽的序列》


    算下作为最小值的最大长度,然后找下最大的。

    // Author: levil
    #include<bits/stdc++.h>
    using namespace std;
    typedef long long LL;
    typedef pair<int,int> pii;
    const int N = 2e6+5;
    const int M = 1e6+5;
    const LL Mod = 1e9+7;
    #define rg register
    #define pi acos(-1)
    #define INF 1e9
    #define CT0 cin.tie(0),cout.tie(0)
    #define IO ios::sync_with_stdio(false)
    #define dbg(ax) cout << "now this num is " << ax << endl;
    namespace FASTIO{
        inline LL read(){
            LL x = 0,f = 1;char c = getchar();
            while(c < '0' || c > '9'){if(c == '-') f = -1;c = getchar();}
            while(c >= '0' && c <= '9'){x = (x<<1)+(x<<3)+(c^48);c = getchar();}
            return x*f;
        }
        void print(int x){
            if(x < 0){x = -x;putchar('-');}
            if(x > 9) print(x/10);
            putchar(x%10+'0');
        }
    }
    using namespace FASTIO;
    void FRE(){/*freopen("data1.in","r",stdin);
    freopen("data1.out","w",stdout);*/}
    
    int a[N],L[N],r[N],S[N];
    int main()
    {
        int n;n = read();
        for(rg int i = 1;i <= n;++i) a[i] = read();
        int top = 0;
        S[++top] = 0;
        a[0] = -1,a[n+1] = -1;
        for(rg int i = 1;i <= n+1;++i)
        {
            while(top != 0 && a[i] < a[S[top]])
            {
                r[S[top]] = i;
                L[S[top]] = S[top-1];
                top--;
            }
            S[++top] = i;
        }
        LL ans = -1;
        for(rg int i = 1;i <= n;++i)
        {
            ans = max(ans,1LL*a[i]*(r[i]-L[i]-1));
        }
        printf("%lld
    ",ans);
       // system("pause");    
    }
    View Code
  • 相关阅读:
    我查询的问题点
    更改hosts操作
    日常有用的网站
    加入到java后台开发
    知识点收藏
    Mac操作技巧
    设置自己的APP能打开文件(在其他应用中打开显示自己的应用)
    思维不要留在框里
    X RMAN Crosscheck后delete obsolete遇到RMAN-06091的解决
    X No standby redo logfiles created for thread 1
  • 原文地址:https://www.cnblogs.com/zwjzwj/p/13675436.html
Copyright © 2020-2023  润新知