Cod sursa(job #1385806)
Utilizator | Diana Pislaru dianaa21 | Data | 12 martie 2015 13:35:36 |
---|---|---|---|
Problema | Interclasari | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.54 kb |
#include <fstream>
#include <queue>
using namespace std;
ifstream is ("interclasari.in");
ofstream os ("interclasari.out");
priority_queue<int, vector<int>, greater<int> >Q;
int N, K, x, S;
int main()
{
is >> N;
for(int i = 1; i <= N; ++i)
{
is >> K;
S += K;
for(int j = 1; j <= K; ++j)
{
is >> x;
Q.push(x);
}
}
os << S << "\n";
while(!Q.empty())
{
os << Q.top() << " ";
Q.pop();
}
is.close();
os.close();
return 0;
}