Cod sursa(job #2153674)

Utilizator bebeetarepredescu bebeetare Data 6 martie 2018 13:29:15
Problema Subsir crescator maximal Scor 10
Compilator cpp Status done
Runda Arhiva educationala Marime 0.4 kb
#include <fstream>

using namespace std;
int n,i,x,vf,sol[100005],j;
ifstream f("scmax.in");
ofstream g("scmax.out");
int main()
{
    f>>n;
    for(i=1;i<=n;i++)
    {
        f>>x;
        j=vf;
        while(vf>0 && sol[vf]>=x)
        {
            vf--;
        }
        sol[++vf]=x;
    }
    g<<vf<<'\n';
    for(i=1;i<=vf;i++)
    {
        g<<sol[i]<<" ";
    }
    return 0;
}