/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 324.0 KiB
#2 Accepted 2ms 324.0 KiB

Code

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define endl '\n'

void solve(int cs){
    int n;cin>>n;
    std::vector<int>v(n);
    for(auto &i:v)cin>>i;
    
    sort(v.begin(),v.end());
    int j = 1;
    for(int i = 0; i < n; i++){
        if(v[i] == j)j++;
        else{
            cout<<"NO"<<endl;
            return;
        }
    }
    cout<<"YES"<<endl;

}
   
int main()
{

    ios_base::sync_with_stdio(false);cin.tie(0);
    int t=1,cs=0;
    cin >> t;
    while(t--)
    {
        solve(++cs);
    }

    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:04:01
Judged At
2024-11-11 03:35:22
Judged By
Score
100
Total Time
2ms
Peak Memory
324.0 KiB