Pagini recente » Clasament test_round_1_2_3 | Cod sursa (job #1110588) | Istoria paginii utilizator/uaic_popa_padurariu_pavaloi | Istoria paginii utilizator/cnmv_dinu_olteanu_virghileanu | Cod sursa (job #245874)
Cod sursa(job #245874)
#include<fstream>
#define maxx 100001
using namespace std;
ifstream fin("scmax.in");
ofstream fout("scmax.out");
int main()
{
int l[maxx],a[maxx],n,i,j,max,maxi;
fin>>n;
for(i=1;i<=n;i++)
fin>>a[i];
for(i=n;i>=1;i--)
{
max=l[i];
for(j=i;j<=n;j++)
if(a[j]>a[i] && max<l[j])
max=l[j];
l[i]=1+max;
if(maxi<l[i])
maxi=l[i];
}
fout<<maxi<<'\n';
for(i=1;i<=n;i++)
if(l[i]==maxi)
fout<<a[i]<<' ',maxi--;
fout<<'\n';
fout.close();
return 0;
}