/* Simple DP, to record the sequential solution: first sort, then a longest descent subsequence, the middle need to record order Dp[i]=max (DP[I],DP[J]+1); */#include <stdio.h> #include <string.h> #include <stdlib.h> #define N 1100/*w,s represents weight and speed, Index records the order subscript of the original input, pre points to the last subscript after sorting, answer records the optimal value for each position after sorting */typedef struct NODE {int w,s,index,pre,answer;}
F
F F[n];
int cmp (const void *a,const void *b) {return (* (* (f *) a). W (* (f *) b). {} void print (int k) {if (f[k].pre==-1) {
printf ("%d\n", F[k].index);
Return
} print (F[k].pre);
printf ("%d\n", F[k].index);
} int main () {int n=0,w,s,i,j,k,index;
while (scanf ("%d%d", &f[n].w,&f[n].s)!=eof) f[n].index=n+1,n++;
Qsort (F,n,sizeof (f[0]), CMP);
for (i=0;i<n;i++) {//printf ("%d%d\n", F[I].W,F[I].S);
F[i].pre=-1;
F[i].answer=1; for (j=0;j<i;j++) if (f[i].w>f[j].w&&f[i].s<f[j].s&&f[i].answer<f[j].answer+1) f[i].
Answer=f[j].answer+1,f[i].pre=j;
printf ("%d%d\n", f[i].answer,f[i].pre);
} k=-1; for (i=0;i<n;i++) if (k<f[i].answer) {k=f[i].answer;
index=//} printf ("%d\n", k);//number of print (index),//recursive output requires a number of sequential return 0;}