QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#129110 | #1171. Integer Array Shuffle | zhangbeixiyan | WA | 1ms | 3908kb | C++14 | 527b | 2023-07-21 21:38:30 | 2023-07-21 21:38:47 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+5;
int n,ans,a[maxn];
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;i++) scanf("%d",&a[i]);
int toL=unique(a+1,a+n+1)-(a+1);
int fl=0,ch=0;
for(int i=2;i<=toL;i++) if(a[i]>a[i-1]) fl=1;
if(!fl && toL!=1)
{
cout<<1<<endl;
return 0;
}
int cur=0;
for(int i=2;i<=toL;i++) if(a[i]>a[i-1] && a[i]>a[i+1]) ans++;
if(ans==0)
{
cout<<0<<endl;
return 0;
}
if(a[n]>a[n-1]) ans++;
cout<<ceil(log2(ans))+1<<endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3596kb
input:
3 2 2 5
output:
0
result:
ok 1 number(s): "0"
Test #2:
score: 0
Accepted
time: 1ms
memory: 3768kb
input:
6 1 5 8 10 3 2
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3908kb
input:
8 14253630 18210471 431833031 681754868 791250850 811241570 837112104 858531105
output:
2
result:
wrong answer 1st numbers differ - expected: '0', found: '2'