Cod sursa(job #2082020)

Utilizator Zamfirescuste2Zamfirescu Stefan Zamfirescuste2 Data 5 decembrie 2017 16:55:05
Problema Subsir crescator maximal Scor 65
Compilator cpp Status done
Runda Arhiva educationala Marime 0.61 kb
#include <fstream>
using namespace std;
ifstream f ("scmax.in");
ofstream g ("scmax.out");
long long  v[100001],s[100001],aux[100001],n,i,j,max1,k;
int main()
{
    f >> n;
    for (i = 1; i <= n; i++ )
    {
         f >> v[i];
         j = 1;
         while ( s[j] < v[i] && j <= max1 )
            j++;
         s[j] = v[i];
         if ( j > max1 )
         {
             max1 = j;
             for ( k = 1; k <= max1; k++ )
                aux[k] = s[k];
         }
    }
    g << max1 << "\n";
    for (i = 1; i <= max1; i ++ )
        g  << aux[i] << " ";
    g << "\n";
    return 0;
}