QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#601880#9313. Make Maxzhk88719WA 31ms6748kbC++141.7kb2024-09-30 15:15:032024-09-30 15:15:03

Judging History

你现在查看的是最新测评结果

  • [2024-09-30 15:15:03]
  • 评测
  • 测评结果:WA
  • 用时:31ms
  • 内存:6748kb
  • [2024-09-30 15:15:03]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N=200005;

int t;
int skt1[N],skt2[N],ans1[N],ans2[N];
ll tt1,tt2,n,a[N],sum,num;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cin>>t;
    while(t--)
    {
        memset(ans1,0,sizeof ans1);
        memset(ans2,0,sizeof ans2);
        tt1=0,tt2=0,sum=0,num=0;
        cin>>n;
        for(int i=0;i<n;i++)
        {
            num=0;
            cin>>a[i];
            while(tt1&&skt1[tt1]<a[i])
            {
                num=ans1[tt1];
                ans1[tt1]=0;
                tt1--;
                ans1[tt1]+=num;
            }
            if(!tt1)
            {
                skt1[++tt1]=a[i];
                ans1[tt1]++;
                sum+=ans1[0];
                continue;
            }
            if(skt1[tt1]==a[i])
            {
                skt1[++tt1]=a[i];
                ans1[tt1]++;
                continue;
            }
            sum+=num;
            skt1[++tt1]=a[i];
            ans1[tt1]++;
        }
        for(int i=n-1;i>-1;i--)
        {
            num=0;
            while(tt2&&skt2[tt2]<a[i])
            {
                num=ans2[tt2];
                ans2[tt2]=0;
                tt2--;
                ans2[tt2]+=num;
            }
             if(!tt2)
             {
                 sum+=ans2[0];
                 skt2[++tt2]=a[i];
                 ans2[tt2]++;
                 continue;
             }
            sum+=num;
            skt2[++tt2]=a[i];
            ans2[tt2]++;
        }
        cout<<sum;
        if(t>0) cout<<endl;
        }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 6084kb

input:

4
2
1 2
2
2 2
7
1 1 1 2 2 2 2
3
1 2 3

output:

1
0
3
3

result:

ok 4 number(s): "1 0 3 3"

Test #2:

score: -100
Wrong Answer
time: 31ms
memory: 6748kb

input:

2
198018
875421126 585870339 471894633 383529988 625397685 944061047 704695631 105113224 459022561 760848605 980735314 847376362 980571959 329939331 644635272 326439858 752879510 837384394 175179068 182094523 397239381 1199016 185143405 279638454 252374970 822030887 860312140 137248166 993229443 164...

output:

2222202
2411331

result:

wrong answer 1st numbers differ - expected: '4084978', found: '2222202'