竞赛讨论区 > A题,全WA了。有大佬能帮忙看看错哪了吗?

A题,全WA了。有大佬能帮忙看看错哪了吗?

头像
Jor蛋
发布于 2022-01-24 12:33:09 APP内打开
赞 0 | 收藏 0 | 回复0 | 浏览436
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
int a[N];
int main(){
    int t;
    scanf("%d",&t);
    while(t--){
        int n;
        scanf("%d",&n);
        int maxx=0,now=0;
        int last;
        for(int i=1;i<=n;i++){    
            scanf("%d",&a[i]);
            if(i==1) last=a[1];
            if(a[i]>=last){
                now+=a[i]-last;
                maxx=max(maxx,now);
            }else {now=0;}
            last=a[i];
        }
//         cout<<maxx<<endl;
       
        now=0;last=a[1];
            int l=1;
            for(int i=1;i<=n;i++){
                if(a[i]>=last){
                    now+=a[i]-last;
//                     cout<<now<<endl;
                    if(now==maxx){
                        int j=i;
                        while(j<=n&&a[i]==a[j]) j++;
                        i=j-1;
                        printf("%d %d ",l,i);
                        now=0;l=i+1;
                    }
                }else{
                    l=i;
                    now=0;
                }
                last=a[i];
            }
            puts("");
        
    }
}


0条回帖

回帖
加载中...
话题 回帖

近期热帖

等你来战

查看全部

热门推荐