/ SeriousOJ /

Record Detail

Runtime Error


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 332.0 KiB
#2 Runtime Error 1ms 284.0 KiB

Code


#include <stdio.h>

int main(){
    int x = 0, t;

    scanf("%d", &t);

    while(x < t){



        int n;
        scanf("%d", &n);

        int ara[n], ara2[n];

        for (int i = 0; i < n; i++){
            scanf("%d", &ara[i]);
        }

        int min, min_ind;

        for(int i = 0; i < n; i++){
            min = ara[i];
            for(int j = 0; j < n; j++){
                if(min >  ara[j]){
                    min = ara[j];
                    min_ind = j;
                }
            }
            ara2[i] = min;
            ara[min_ind] = 100000;
        }

        for(int i = 1; i <= n; i++){
            if(ara2[i-1] != i){
                printf("NO\n");
                break;
            }

            if(i == n){
               printf("YES\n");
            }
        }
        x++;

    }

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1055 Array Permutation
Contest
Brain Booster #3
Language
C99 (GCC 13.2.0)
Submit At
2024-05-06 15:50:32
Judged At
2024-11-11 03:33:48
Judged By
Score
0
Total Time
1ms
Peak Memory
332.0 KiB