Cod sursa(job #1740711)

Utilizator tudorgalatanRoman Tudor tudorgalatan Data 12 august 2016 09:10:48
Problema Interclasari Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.83 kb
#include <fstream>

using namespace std;

unsigned short int K;
unsigned int Ni;
unsigned int photos[20000001];

unsigned int temp;
unsigned int i, j;

unsigned int X;

int main ()
{
    ifstream fin ("interclasari.in");
    fin >> K;
    for (i=1; i<=K; i++)
    {
        fin >> Ni;
        for (j=1; j<=Ni; j++)
        {
            X++;
            fin >> photos[X];
        }
    }
    fin.close();
    for (i=1; i<=X; i++)
    {
        for (j=2; j<=X; j++)
            if (photos[j] < photos[j-1])
            {
                temp = photos[j];
                photos[j] = photos[j-1];
                photos[j-1] = temp;
            }
    }
    ofstream fout ("interclasari.out");
    fout << X << '\n';
    for (i=1; i<=X; i++)
        fout << photos[i] << ' ';
    fout.close();
    return 0;
}