Cod sursa(job #1724550)

Utilizator bciobanuBogdan Ciobanu bciobanu Data 3 iulie 2016 15:08:38
Problema Sortare prin comparare Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.97 kb
#include <cstdio>
#include <cctype>
#include <algorithm>

using namespace std;

constexpr int MAX_N = 500000;
constexpr int BUFFSIZE = (1 << 13);

inline char getChar() {
    static char buff[BUFFSIZE];
    static int pos = 0;
    if (__builtin_expect(pos == BUFFSIZE, 0)) {
        fread(buff, 1, BUFFSIZE, stdin);
        pos = 0;
    }
    return buff[pos++];
}

inline int readInt() {
    int q = 0;
    char c;
    do {
        c = getChar();
    } while (!isdigit(c));
    do {
        q = (q << 1) + (q << 3) + (c - '0');
        c = getChar();
    } while (isdigit(c));
    return q;
}

int v[MAX_N];

int main() {
    freopen("algsort.in", "r", stdin);
    freopen("algsort.out", "w", stdout);
    int n = readInt();
    for (int i = 0; i < n; i += 1) {
        v[i] = readInt();
    }
    fclose(stdin);
    sort(v, v + n);
    for (int i = 0; i < n; i += 1) {
        printf("%d " , v[i]);
    }
    fclose(stdout);
    return 0;
}