Code
#include <iostream>
#include <algorithm>
using namespace std;
void solve()
{
int n;
cin >> n;
int a[n];
for (int i = 0; i < n; i++)
cin >> a[i];
int result = 0;
sort (a, a+n);
for (int i = 0; i < n; i++)
{
if (a[i] != i + 1)
{
result++;
break;
}
}
cout << (result == 0 ? "YES" : "NO") << endl;
}
int main()
{
int t;
cin >> t;
while (t--)
solve();
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:22:28
- Judged At
- 2024-11-11 03:34:36
- Judged By
- Score
- 100
- Total Time
- 4ms
- Peak Memory
- 540.0 KiB