QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#576814#9313. Make Maxeden369WA 1ms5708kbC++14795b2024-09-19 22:37:132024-09-19 22:37:14

Judging History

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

  • [2024-09-19 22:37:14]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5708kb
  • [2024-09-19 22:37:13]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

int n,m;
const int N=1e6+10;
int a[N];
int l[N];
int r[N];
int main(){
    int t;
    cin>>t;
    while(t--)
    {
        int ans=0;
        int n;
        cin>>n;
        for(int i=1;i<=n;i++)
        {
            cin>>a[i];
        }
        for(int i=2;i<=n;i++)
        {
            if(a[i]>a[i-1])
            {
                l[i]=l[i-1]+1;
            }
            else l[i]=0;
        }
        for(int i=n-1;i>=1;i--)
        {
            if(a[i+1]<a[i])
            {
                r[i]=r[i+1]+1;
            }
            else r[i]=0;
        }
        int an=0;
        for(int i=1;i<=n;i++)
        {
            an+=r[i]+l[i];
        }
        cout<<an<<endl;
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 5708kb

input:

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

output:

1
0
1
3

result:

wrong answer 3rd numbers differ - expected: '3', found: '1'