Cod sursa(job #2038919)

Utilizator stefanxdanDanila Sergiu Stefan stefanxdan Data 14 octombrie 2017 10:00:59
Problema Interclasari Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.51 kb
#include <bits/stdc++.h>

using namespace std;

ifstream fin("interclasari.in");
ofstream fout("interclasari.out");

priority_queue <int> q;
int k, L, cnt, x;

int main()
{
    fin >> k;
    for( int i =1; i <= k; i++)
    {
        fin >> L;
        cnt+=L;
        for( int j=1; j <= L; j++)
        {
            fin >> x;
            q.push(-x);
        }
    }

    fout << cnt << "\n";
    while( !q.empty())
    {
        fout << -q.top() << " ";
        q.pop();
    }
    return 0;
}