-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
35 lines (33 loc) · 676 Bytes
/
main.cpp
File metadata and controls
35 lines (33 loc) · 676 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
#include <iostream>
#include <vector>
using namespace std;
void solve(vector<int>& v, int n, int k) {
bool isSorted = true;
for (int i = 0; i < n - 1; ++i) {
if (v[i] <= v[i + 1]) {
continue;
}
isSorted = false;
break;
}
if (isSorted) {
cout<<"YES"<<"\n";
return;
}
// if k is 1 then it's not possible to arrange
cout<<(k == 1 ? "NO" : "YES")<<"\n";
}
int main() {
int t;
cin >> t;
while(t--) {
int n, k;
cin>>n>>k;
vector<int> v(n);
for (int i = 0; i < n; ++i) {
cin>>v[i];
}
solve(v, n, k);
}
return 0;
}