Cod sursa(job #2068157)
Utilizator | Data | 17 noiembrie 2017 11:44:00 | |
---|---|---|---|
Problema | Subsir crescator maximal | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.59 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("scmax.in");
ofstream c("scmax.out");
int main()
{
int n,a[1000],S[1000],p[1000];
f>>n;
for(int i=1;i<=n;i++)
f>>a[i];
int k,Lmax=0;
for(int i=1;i<n;i++){
p[0]=a[i];
k=0;
for(int j=i+1;j<=n;j++){
if(a[p[k]]<a[j]){
p[k+1]=a[j];
k++;
}
}
if(k+1>L){
Lmax=k+1;
for(int l=0;l<Lmax;l++)
S[l]=p[l];}
}
c<<L<<endl;
for(int l=0;l<Lmax;l++)
c<<S[l]<<" ";
return 0;
}