█████████ ████ ███░░░░░███ ░░███ ███ ░░░ ██████ ███████ ██████ ██████ ░███ ███░░███ ███░░███ ███░░███ ███░░███ ░███ ░███ ░███░███ ░███ ░███████ ░███ ░███ ░░███ ███░███ ░███░███ ░███ ░███░░░ ░███ ░███ ░░█████████ ░░██████ ░░████████░░██████ ░░██████ ░░░░░░░░░ ░░░░░░ ░░░░░░░░ ░░░░░░ ░░░░░░

Envío 1918

Problema 0xdd - Ordenar un arreglo pequeño

  • Autor: ppastram
  • Fecha: 2020-11-10 15:17:53 UTC (Hace más de 3 años)
Caso # Resultado Tiempo Memoria
#1
Incorrecto
0.006 s 1 KBi
#2
Incorrecto
0.006 s 16 KBi
#3
Incorrecto
0.006 s 1 KBi
#4
Incorrecto
0.006 s 1 KBi
#5
Incorrecto
0.006 s 1 KBi
#6
Incorrecto
0.005 s 1 KBi
#7
Incorrecto
0.005 s 1 KBi
#8
Incorrecto
0.006 s 1 KBi
#9
Incorrecto
0.005 s 1 KBi
#10
Incorrecto
0.005 s 1 KBi
#11
Incorrecto
0.132 s 3 KBi
#12
Incorrecto
0.072 s 4 KBi
#13
Incorrecto
0.089 s 4 KBi
#14
Error en tiempo de ejecución (NZEC)
Exited with error status 153
run: line 1:     3 File size limit exceeded(core dumped) ./a.out
0.041 s 6 KBi
#15
Error en tiempo de ejecución (NZEC)
Exited with error status 153
run: line 1:     3 File size limit exceeded(core dumped) ./a.out
0.046 s 5 KBi
#16
Incorrecto
0.081 s 5 KBi
#17
Incorrecto
0.089 s 5 KBi
#18
Incorrecto
0.088 s 5 KBi
#19
Error en tiempo de ejecución (NZEC)
Exited with error status 153
run: line 1:     3 File size limit exceeded(core dumped) ./a.out
0.046 s 5 KBi
#20
Error en tiempo de ejecución (NZEC)
Exited with error status 153
run: line 1:     3 File size limit exceeded(core dumped) ./a.out
0.048 s 5 KBi
Puntos totales: 0 / 100

Código

#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <algorithm>
#define forn(a, n) for(int a = 0; a<(int) (n); ++a)
#define rforn(a, n) for(int a = (n)-1; a>=0; --a)
using namespace std;
const int N = 6e5+20;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n, pos, temp;
    cin>>n;
    int a [1001];
    for(int i = 0; i < n; i++)
    {
        cin>>a[i];
    }

    // --- SELECTION SORT --- -> el lado izquiero va quedando ordenando, va agregando el elemento menor de la parte derecha
    for(int i = 0; i < n-1; i++)
    {
        int min = N;

        for(int j = i; j < n; j++)
        {
            if(a[j] < min)
            {
                min = a[j];
                pos = j;
            }
        }

        if(min != N)
        {
            temp = a[i];
            a[i] = a[pos];
            a[pos] = temp;
        }

        for(int i = 0; i < n; i++)
        {
            cout<<a[i]<<" ";
        }
        cout<<endl;
    }

    for(int i = 0; i < n; i++)
    {
        cout<<a[i]<<" ";
    }
    cout<<endl;
}