-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1Untitled1.cpp
More file actions
48 lines (44 loc) · 735 Bytes
/
1Untitled1.cpp
File metadata and controls
48 lines (44 loc) · 735 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
#include<bits/stdc++.h>
using namespace std;
int isSorted(long long int a[],long long int n)
{ long long int arr[n];
for(long long int i=0;i<n;i++)
arr[i]=a[i];
int l=0;
sort(arr,arr+n);
for(long long int i=0;i<n;i++)
{
if(arr[i]==a[i])
l=1;
else {
l=0; break;
}
}
if(l==1) return 1;
else if(l==0) return 0;
}
int main()
{ int t;
cin>>t;
for(int i=0;i<t;i++)
{
long long int n,k;
cin>>n>>k;
long long int a[n];
for(long long int j=1;j<=n;j++)
cin>>a[j];
for(long long int j=1;j<=n-k+1;j++)
{ if(a[j]>a[j+k])
{
long long int temp;
temp=a[j];
a[j]=a[j+k];
a[j+k]=temp;
}
}
if(isSorted(a,n))
cout<<"yes";
else cout<<"no";
}
return 0;
}