/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 3ms 532.0 KiB

Code

#include <iostream>
using namespace std;
int main(){
    int t;
    cin>>t;
    for(int i=0;i<t;i++){
        int n;
        cin>> n;
        int A[n];
        for(int j=0;j<n;j++){
            cin>> A[j];
        }
        for(int j=0;j<n-1;j++){
            for(int k=j+1;k<n;k++){
                if(A[k]<A[j]){
                int temp=A[k];
                A[k]=A[j];
                A[j]=temp;
            }
            }
        }
        int B[n];
        for(int j=0;j<n;j++){
            int num =j+1;
            B[j]=num;
        }
        
        int p=0;
        for(int j=0;j<n;j++){
            if(A[j]==B[j]){
                p++;
            }
        }
        if(p==n){
            cout <<"YES\n";
        }
        else {
            cout << "NO\n";
        }
    }
}

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:45:03
Judged At
2024-11-11 03:33:55
Judged By
Score
100
Total Time
3ms
Peak Memory
532.0 KiB