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

Envío 5432

Problema 0xde - Ordenar un arreglo grande

  • Autor: DanielP
  • Fecha: 2021-12-16 04:53:39 UTC (Hace más de 2 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.004 s 5 KBi
#2
Correcto
0.003 s 0 KBi
#3
Correcto
0.004 s 0 KBi
#4
Correcto
0.004 s 3 KBi
#5
Correcto
0.004 s 2 KBi
#6
Correcto
0.006 s 0 KBi
#7
Tiempo límite excedido
1.082 s 3 KBi
#8
Tiempo límite excedido
1.013 s 2 KBi
#9
Tiempo límite excedido
1.059 s 1 KBi
#10
Tiempo límite excedido
1.063 s 5 KBi
#11
Tiempo límite excedido
1.081 s 1 KBi
#12
Tiempo límite excedido
1.069 s 1 KBi
#13
Correcto
0.115 s 1 KBi
#14
Correcto
0.078 s 1 KBi
#15
Correcto
0.098 s 7 KBi
#16
Correcto
0.037 s 2 KBi
#17
Correcto
0.096 s 2 KBi
#18
Correcto
0.073 s 1 KBi
#19
Correcto
0.072 s 1 KBi
#20
Tiempo límite excedido
1.027 s 3 KBi
#21
Correcto
0.099 s 1 KBi
#22
Correcto
0.095 s 1 KBi
#23
Correcto
0.086 s 1 KBi
#24
Correcto
0.074 s 1 KBi
#25
Correcto
0.075 s 1 KBi
#26
Correcto
0.113 s 3 KBi
#27
Correcto
0.045 s 1 KBi
Puntos totales: 75 / 100

Código

/// Write by Daniel Perez .PERAPRO
#include<bits/stdc++.h>

using namespace std;
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(), s.end()
#define mp make_pair
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using vi=vector<int>;
using vl=vector<ll>;
using pii=pair<int,int>;
char el = '\n';
char esp = ' ';

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

ostream& operator<<(ostream& os, const vector<int> &v){
    for(auto const &i: v){
        os<<i<<" ";
    }
    os<<'\n';
    return os;
}
string yes="YES";
string no="NO";

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int partition(vi &v, int p, int r){
    int x = v[r];
    int i = p - 1;
    for(int j = p;j<=r - 1;j++){
        if(v[j] <= x){
            i = i + 1;
            swap(v[i], v[j]);
        }
    }
    swap(v[i + 1], v[r]);
    return i + 1;
}

int random_p(vi &v, int p, int r){
    int i = uniform_int_distribution<int>(p, r)(rng);
    swap(v[r], v[i]);
    return partition(v, p, r);
}

void quicksort(vi &v, int p, int r){
    if(p < r){
        int q = random_p(v, p, r);
        quicksort(v, p,q - 1);
        quicksort(v, q + 1,r);
    }
}

int main(){
	fast_io;
	/*
 	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    */
    
    int n;
    cin>>n;
    vi v(n);
    for(int &e:v)
        cin>>e;
        
    shuffle(all(v), rng);
    quicksort(v, 0,n - 1);
    cout<<v;
}

/*

*/