Cod sursa(job #2251129)
Utilizator | Data | 1 octombrie 2018 10:10:01 | |
---|---|---|---|
Problema | Subsir crescator maximal | Scor | 20 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 1.28 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("scmax.in");
ofstream fout("scmax.out");
int n,i,j,t,nr,nrmax,V[100001],sol[100001],solmax[100001];
int main()
{fin>>n;
for(i=1;i<=n;i++)
fin>>V[i];
for(i=1;i<n;i++){
nr=1;
sol[nr]=V[i];
for(j=i+1;j<=n;j++){
if(V[j]>sol[nr]){
nr++;
sol[nr]=V[j];
}
}
if(nr>nrmax){
nrmax=nr;
for(t=1;t<=nr;t++)
solmax[t]=sol[t];
}
}
fout<<nrmax<<"\n";
for(i=1;i<=nrmax;i++)
fout<<solmax[i]<<" ";
return 0;
}