QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#534337 | #1171. Integer Array Shuffle | 36champ | WA | 0ms | 3860kb | C++20 | 1.1kb | 2024-08-27 03:22:26 | 2024-08-27 03:22:26 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int n;
cin >> n;
vector<int> a(n);
for(int i=0; i<n; i++) cin >> a[i];
bool ok = true;
for(int i=1; i<n; i++) if(a[i] < a[i-1]) ok = false;
if(ok)
{
cout << 0;
return 0;
}
int cnt = 0, l = 0, r = n - 1;
while(l <= r)
{
if(cnt % 2 == 0)
{
int m = min(a[l], a[r]);
while(a[l] >= m || a[r] >= m && l <= r)
{
if(a[l] >= a[r]) r--;
else l++;
}
cnt++;
}
else
{
int M = min(a[l], a[r]);
while(a[l] <= M || a[r] <= M && l <= r)
{
if(a[l] <= a[r]) r--;
else l++;
}
cnt++;
}
}
int ans = 0, now = 1;
while(now < cnt)
{
now *= 2;
ans++;
}
cout << ans + 1;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3548kb
input:
3 2 2 5
output:
0
result:
ok 1 number(s): "0"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
6 1 5 8 10 3 2
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3584kb
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: 3860kb
input:
3 2 2 5
output:
0
result:
ok 1 number(s): "0"
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 3784kb
input:
7 4 2 4 2 5 3 4
output:
1
result:
wrong answer 1st numbers differ - expected: '3', found: '1'