QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#37704 | #1171. Integer Array Shuffle | Froggygua | TL | 2ms | 3540kb | C++17 | 595b | 2022-07-02 15:40:52 | 2022-07-02 15:40:53 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define N 300030
typedef long long ll;
int n,a[N];
bool check(){
for(int i=1;i<n;++i){
if(a[i]>a[i+1]){
return false;
}
}
return true;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cin>>n;
for(int i=1;i<=n;++i){
cin>>a[i];
}
int ans=0;
while(!check()){
++ans;
int l=1,r=n,tot=0;
static int b[N];
while(l<=r){
if(a[l]<=a[r]){
b[++tot]=a[l++];
}
else{
b[++tot]=a[r--];
}
}
for(int i=1;i<=n;++i){
a[i]=b[i];
}
}
cout<<ans<<'\n';
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3540kb
input:
3 2 2 5
output:
0
result:
ok 1 number(s): "0"
Test #2:
score: 0
Accepted
time: 1ms
memory: 3528kb
input:
6 1 5 8 10 3 2
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3496kb
input:
8 14253630 18210471 431833031 681754868 791250850 811241570 837112104 858531105
output:
0
result:
ok 1 number(s): "0"
Test #4:
score: 0
Accepted
time: 2ms
memory: 3508kb
input:
3 2 2 5
output:
0
result:
ok 1 number(s): "0"
Test #5:
score: -100
Time Limit Exceeded
input:
7 4 2 4 2 5 3 4