Cod sursa(job #2281795)

Utilizator sabinpocrisSabin P sabinpocris Data 12 noiembrie 2018 19:01:20
Problema Sortare prin comparare Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.77 kb
#include <bits/stdc++.h>
using namespace std;


vector<int> v;

struct reader
{
  char buff[32010];
  int poz;
  reader()
  {
    freopen("algsort.in","r",stdin);
    freopen("algsort.out","w",stdout);
    poz=31999;
    inc();
  }
  void operator>>(int &x)
  {
    while(buff[poz]<'0'||buff[poz]>'9')
      inc();
    x=0;
    while(buff[poz]>='0'&&buff[poz]<='9')
      {
	x=10*x+buff[poz]-'0';
	inc();
      }
  }
  void operator>>(vector<int> &v)
  {
    int n,x;
    *this >> n;
    v.resize(0);
    for(;n;n--)
      {
	*this >> x;
	v.push_back(x);
      }
    sort(v.begin(),v.end());
    for(auto it:v)
      printf("%d ",it);
  }
  void inc()
  {
    poz++;
    if(poz==32000)
      {
	fread(buff,1,32000,stdin);
	poz=0;
      }
  }
};
int main(){ 
  reader f;
  f>>v;
  return 0;
}