Pagini recente » Cod sursa (job #353751) | Cod sursa (job #1112452) | Cod sursa (job #2371293) | Cod sursa (job #736662) | Cod sursa (job #1487011)
#include <fstream>
#include <queue>
using namespace std;
ifstream f("interclasari.in");
ofstream g("interclasari.out");
const int NMAX=1000005;
int a[NMAX];
struct cmp{
bool operator()(const int A,const int B) const
{
return A>B;
}
};
priority_queue <int,vector<int>,cmp> Q;
int main()
{
int k,sol=0,n;
f>>k;
for(int i=1;i<=k;i++)
{
f>>n;
sol+=n;
for(int j=1;j<=n;j++)
{
f>>a[i];
Q.push(a[i]);
}
}
g<<sol<<"\n";
while(sol>0)
{
g<<Q.top()<<" ";
sol--;
Q.pop();
}
return 0;
}