Cod sursa(job #2291246)

Utilizator DordeDorde Matei Dorde Data 27 noiembrie 2018 19:52:07
Problema Interclasari Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.89 kb
#include <fstream>
#include <queue>

using namespace std;
void Init (char const x []){
    freopen (x , "r" , stdin);
}
int const BUFF = 1e6;
char buff [BUFF];
int p;
void nextc (){
    if (++ p == BUFF){
        p = 0;
        fread (buff , 1 , BUFF , stdin);
    }
}
int next (){
    int a = 0;
    while (! isdigit (buff [p]))
        nextc ();
    while (isdigit (buff [p])){
        a = a * 10 + buff [p] - '0';
        nextc ();
    }
    return a;
}
priority_queue <int , vector <int> , greater <int> > q;
ofstream g ("interclasari.out");
int main()
{
    Init ("interclasari.in");
    int k;
    k = next ();
    while (k --){
        int a;
        a = next ();
        while (a --)
            q . push (next ());
    }
    g << q . size () << '\n';
    while (! q . empty ()){
        g << q . top () << ' ';
        q . pop ();
    }
    return 0;
}