Pagini recente » Cod sursa (job #2047698) | Cod sursa (job #11343) | Cod sursa (job #1476831) | Cod sursa (job #2965129) | Cod sursa (job #2063143)
#include <fstream>
using namespace std;
ifstream f("subsir2.in");
ofstream g("subsir2.out");
int n,i,a[1005],b[1005],l[1005],lmax=0,s=0,min1,j,k;
void solve()
{
int i,j,p,maxim=0;
for(i=n; i>=1; i--)
{maxim=0;
for(j=i+1; j<=n; j++)
{
if(a[i]<a[j]&&l[j]>maxim)maxim=l[j];
}
l[i]=maxim+1;
/*if(l[i]==1)nr[i]=1;
else{
for(j=i+1;j<=n;j++)
{
if(l[j]==l[i]-1&&a[j]>a[i])
nr[i]=(nr[i]+nr[j])%9901;
}
}
*/
}
}
int main()
{
f>>n;
for(i=1; i<=n; i++)
f>>a[i];
l[n]=1;
solve();
for(i=1;i<=n;i++)
{
if(l[i]>lmax)lmax=l[i];
}
g<<lmax<<'\n';
for(i=lmax;i>=1;i--)
{min1=99999999;
for(j=1;j<=n;j++)
if(l[j]==i){if(min1>a[j]){k=j;}}
g<<k<<" ";
}
return 0;
}