Code
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
bool m(vector<int> &a, int n) {
sort(a.begin(), a.end());
for (int i = 0; i < n; ++i) {
if (a[i] != i + 1) {
return false;
}
}
return true;
}
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
if (m(a, n)) {
cout << "YES\n";
} else {
cout << "NO\n";
}
}
return 0;
}
Information
- Submit By
- Type
- Submission
- Problem
- P1055 Array Permutation
- Contest
- Brain Booster #3
- Language
- C++20 (G++ 13.2.0)
- Submit At
- 2024-05-06 15:06:39
- Judged At
- 2024-11-11 03:35:15
- Judged By
- Score
- 100
- Total Time
- 3ms
- Peak Memory
- 484.0 KiB