题解 | #有序序列判断#
有序序列判断
https://www.nowcoder.com/practice/22e87f8a8d764a6582710f38d1b40c6e
#include <bits/stdc++.h> #include <vector> using namespace std; int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } vector<int> b(n), c(n); b = c = a; sort(a.begin(), a.end()); sort(b.begin(), b.end(), greater()); if (c == b || c == a) cout << "sorted"; else cout << "unsorted"; }