#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
#define MAX 10000
int I,len[MAX],pre[MAX],output[MAX],i,j,maX,highest;
class elephant{
public:
int iq,weight,index;
};
bool comp(elephant a,elephant b)
{
if (a.iq>=b.iq)return true;
else return false;
}
int main()
{
int W,IN=0;
I=0;
elephant ele[MAX];
while(scanf("%d %d",&W,&IN)!=EOF)
{ele[I].weight=W;
ele[I].iq=IN;
ele[I].index=I+1;
I++;
}
sort(ele,ele+I,comp);
//int res=lis(I);
for(i=0;i<I;i++){pre[i]=i;len[i]=1;}
for(i=0;i<I-1;i++)
for(j=i+1;j<I;j++)
{
if(ele[i].weight<ele[j].weight && len[i]+1>len[j]){len[j]=len[i]+1;pre[j]=i;}
}
maX=0;
for(i=0;i<I;i++)if(maX<len[i]){maX=len[i];highest=i;}
cout<<maX<<endl;
//output
for(i=maX;i>0;i--){output[i]=highest;
highest=pre[highest];
}
for(i=1;i<=maX;i++)cout<<ele[output[i]].index<<endl;
return 0;
}
code na diya problem ta niye in details discuss krle and tricky part gula figure out krle valo hoi na , Imtiaz Naved ?? :D
উত্তরমুছুন