-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsorting_the_skills.cpp
More file actions
56 lines (54 loc) · 949 Bytes
/
sorting_the_skills.cpp
File metadata and controls
56 lines (54 loc) · 949 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include<bits/stdc++.h>
using namespace std;
void swap(int ar[],int i,int j)
{
int t=ar[j];
ar[j]=ar[i];
ar[i]=t;
return;
}
int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
int ar[n];
int flag=0;
for(int i=0;i<n;i++)
{
cin>>ar[i];
}
int i=0;
int j=1;
while(j<=n-1)
{
if(ar[i]>ar[j])
{
if(ar[i]-ar[j]==1)
{
swap(ar[i],ar[j]);
}
else
{
flag=1;
cout<<"No"<<endl;
break;
}
}
if(flag==1)
{
break;
}
i++;
j++;
}
if(flag==0)
{
cout<<"Yes"<<endl;
}
}
return 0;
}