-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1903a.cpp
More file actions
37 lines (34 loc) · 859 Bytes
/
1903a.cpp
File metadata and controls
37 lines (34 loc) · 859 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
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n, k;
cin >> n >> k;
vector<int> a(n);
for (int i = 0; i < n; i++) cin >> a[i];
// Manual checking for sorting
// if (k > 1) {
// cout << "YES\n";
// } else {
// bool sorted = true;
// for (int i = 1; i < n; i++) {
// if (a[i] < a[i-1]) {
// sorted = false;
// break;
// }
// }
// cout << (sorted ? "YES\n" : "NO\n");
// }
// Using in built
if (k > 1) {
cout << "YES\n";
} else {
cout << (is_sorted(a.begin(), a.end()) ? "YES\n" : "NO\n");
}
}
return 0;
}