QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#127829 | #1171. Integer Array Shuffle | Dr_Glitch | WA | 1ms | 3596kb | C++14 | 1.0kb | 2023-07-20 09:19:38 | 2023-07-20 09:19:41 |
Judging History
answer
#include<bits/stdc++.h>
#define init read()
using namespace std;
int n,ans=0;
vector<int>vec;
inline int read()
{
int mmm=0,ff=1;char xx=getchar();
while((xx<'0'||xx>'9')&&xx!='-')xx=getchar();
if(xx=='-')ff=-1,xx=getchar();
while(xx>='0'&&xx<='9')
mmm=mmm*10+xx-'0',xx=getchar();
return mmm*ff;
}
inline void write(int x)
{
if(x<0)
{
putchar('-');
x=-x;
}
if(x>9)write(x/10);
putchar('0'+x%10);
}
int main()
{
//freopen("qoj1171.in","r",stdin);
//freopen("qoj1171.out","w",stdout);
n=init;bool flag=true;int last=0;
for(int i=1;i<=n;i++)
{
int x=init;if(x<last)flag=false;
last=x;
vec.emplace_back(x);
}
if(vec.size()==1u||flag)
{
puts("0");
return 0;
}
last=vec[0];bool up=true;
for(int i=1;(unsigned)i<vec.size();i++)
{
int now=vec[i];
if(now>=last&&up)
{
if(i==1)ans=1;
last=now;
continue;
}
if(now<=last&&!up)
{
if(i==1)ans=1;
last=now;
continue;
}
last=now;
up=!up;ans++;
}
write(ceil(log2(ans)));putchar('\n');
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3432kb
input:
3 2 2 5
output:
0
result:
ok 1 number(s): "0"
Test #2:
score: 0
Accepted
time: 1ms
memory: 3468kb
input:
6 1 5 8 10 3 2
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 1ms
memory: 3596kb
input:
8 14253630 18210471 431833031 681754868 791250850 811241570 837112104 858531105
output:
0
result:
ok 1 number(s): "0"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3424kb
input:
3 2 2 5
output:
0
result:
ok 1 number(s): "0"
Test #5:
score: 0
Accepted
time: 1ms
memory: 3372kb
input:
7 4 2 4 2 5 3 4
output:
3
result:
ok 1 number(s): "3"
Test #6:
score: 0
Accepted
time: 1ms
memory: 3492kb
input:
8 92691902 57877007 167221695 197382747 709013587 643114183 962487887 112336349
output:
3
result:
ok 1 number(s): "3"
Test #7:
score: 0
Accepted
time: 1ms
memory: 3560kb
input:
8 14253630 811241570 18210471 431833031 858531105 837112104 681754868 791250850
output:
3
result:
ok 1 number(s): "3"
Test #8:
score: 0
Accepted
time: 1ms
memory: 3316kb
input:
8 1 1 1 1 1 1 1 1
output:
0
result:
ok 1 number(s): "0"
Test #9:
score: -100
Wrong Answer
time: 0ms
memory: 3500kb
input:
8 858531105 837112104 811241570 791250850 681754868 431833031 18210471 14253630
output:
0
result:
wrong answer 1st numbers differ - expected: '1', found: '0'