QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#128515 | #1171. Integer Array Shuffle | cztq | WA | 1ms | 3716kb | C++14 | 436b | 2023-07-21 08:11:48 | 2023-07-21 08:11:50 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int n,a[300010],ans,tag;
int main(){
scanf("%d",&n);
for(int i = 1;i<=n;i++)
scanf("%d",&a[i]);
if(a[1]<=a[2]) tag = 1;
else tag = 0,ans++;
for(int i = 3;i<=n;i++){
if(tag&&a[i]<a[i-1]){
ans++;
tag = 0;
}else if(~tag&&a[i]>a[i-1]){
tag = 1;
}
}
if(tag==1&&ans!=0) ans++;
if(ans==0) printf("0");
else printf("%d",(int)log2(ans)+1);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3716kb
input:
3 2 2 5
output:
0
result:
ok 1 number(s): "0"
Test #2:
score: 0
Accepted
time: 1ms
memory: 3556kb
input:
6 1 5 8 10 3 2
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 1ms
memory: 3512kb
input:
8 14253630 18210471 431833031 681754868 791250850 811241570 837112104 858531105
output:
0
result:
ok 1 number(s): "0"
Test #4:
score: 0
Accepted
time: 1ms
memory: 3512kb
input:
3 2 2 5
output:
0
result:
ok 1 number(s): "0"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3688kb
input:
7 4 2 4 2 5 3 4
output:
3
result:
ok 1 number(s): "3"
Test #6:
score: -100
Wrong Answer
time: 1ms
memory: 3628kb
input:
8 92691902 57877007 167221695 197382747 709013587 643114183 962487887 112336349
output:
2
result:
wrong answer 1st numbers differ - expected: '3', found: '2'