QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#595128#5147. Stack Sortlouhao088#WA 25ms5980kbC++23437b2024-09-28 12:39:232024-09-28 12:39:25

Judging History

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

  • [2024-09-28 12:39:25]
  • 评测
  • 测评结果:WA
  • 用时:25ms
  • 内存:5980kb
  • [2024-09-28 12:39:23]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int maxn=5e5+5;
int n,m,a[maxn],T,flag[maxn];
void solve(){
    scanf("%d",&n);m=0;
    for(int i=1;i<=n;i++)flag[i]=0;
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        if(!flag[a[i]+1])m++;
        //cout<<a[i]-1<<" "<<endl;
        flag[a[i]]=1;
    }
    printf("%d\n",m);
}
signed main(){
    scanf("%d",&T);
    while(T--){
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
3
1 2 3
3
3 2 1
5
1 4 2 5 3

output:

3
1
4

result:

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

Test #2:

score: -100
Wrong Answer
time: 25ms
memory: 5980kb

input:

100000
4
3 4 2 1
5
5 4 1 3 2
4
3 1 4 2
4
4 2 1 3
4
1 3 2 4
4
4 2 3 1
4
3 2 1 4
5
1 2 3 4 5
5
5 2 3 1 4
5
1 3 5 4 2
5
4 3 2 1 5
5
3 4 2 1 5
5
5 4 3 2 1
4
3 4 2 1
5
4 2 5 1 3
5
4 1 5 2 3
4
3 4 1 2
4
2 1 3 4
5
4 3 2 5 1
4
4 2 1 3
5
3 1 5 2 4
4
4 1 2 3
5
1 5 2 4 3
5
4 1 3 5 2
5
4 2 3 5 1
5
1 2 3 4 5
5
4...

output:

2
2
2
1
2
1
1
5
3
3
2
3
1
1
3
4
2
2
2
1
3
2
3
3
3
5
4
2
3
1
3
1
3
3
2
1
2
4
1
4
3
2
4
1
2
4
1
2
3
1
3
3
1
3
2
3
1
3
3
3
2
2
2
2
1
3
1
1
3
3
1
1
2
3
2
2
2
3
1
1
2
3
3
3
4
3
3
2
3
3
4
2
1
3
2
1
2
3
2
3
2
4
2
3
1
0
4
1
2
1
1
2
2
1
3
3
1
1
2
2
3
2
4
4
1
2
1
2
1
3
2
2
1
4
3
1
3
3
3
2
3
4
2
2
0
2
3
4
2
3
...

result:

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