Cod sursa(job #3300279)

Utilizator lucian243Condrea Andrei Lucian lucian243 Data 14 iunie 2025 14:01:13
Problema Interclasari Scor 20
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.6 kb
// Source: https://usaco.guide/general/io

#include <bits/stdc++.h>
using namespace std;
ifstream f("interclasari.in");
ofstream g("interclasari.out");
priority_queue<int,vector<int>,greater<int>> pq;
int n,k,x,s,last;
int main() {
	f>>k;
    for(int i=1;i<=k;i++)
    {
        f>>n;
        s+=n;
        for(int j=1;j<=n;j++)
        {
            f>>x; 
             pq.push(x);
        }
    }
        g<<s<<'\n';
        last=pq.top();
        g<<last<<' ';
        pq.pop();
    while(!pq.empty())
    {
       if(pq.top()!=last)
       g<<pq.top()<<' ';
       last=pq.top();
       pq.pop();
        
    }
}