Code
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while(t--)
{
int n;
cin>>n;
int arr[n];
for(int i=0; i<n; i++)
{
cin>>arr[i];
}
sort(arr, arr + n);
int arr2[n];
for(int i=1;i<n+1; i++)
{
arr2[i-1]=i;
}
int flag = 1;
for(int i=0; i<n; i++)
{
if(arr[i] != arr2[i])
{
flag = 0;
break;
}
}
if(flag == 1)
{
cout<<"YES"<<endl;
}
else{
cout<<"NO"<<endl;
}
}
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:15:33
- Judged At
- 2024-11-11 03:34:52
- Judged By
- Score
- 100
- Total Time
- 4ms
- Peak Memory
- 556.0 KiB