Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
为什么不停的RE啊#include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> using namespace std; typedef struct{ int le, mi; }blo; blo b[10005]; int f[10005]; int cmp(const blo &a, const blo &c){ if (a.le>c.le) return 0; else if (a.le==c.le){ if (a.mi>c.mi) return 0; else return 1; } else return 1; } main(){ int n, i, j, k, max; while(scanf("%d",&n),n!=0){ memset(f,-1,sizeof(f)); f[0]=0; b[0].le=0; b[0].mi=0; for (i=1;i<=n;++i) scanf("%d%d",&b[i].le,&b[i].mi); sort(b+1,b+n+1,cmp); for (i=1;i<=n;++i) for (j=0;j<i;++j) if (b[i].le>=b[j].le && b[i].mi>=b[j].mi && f[i]<f[j]+1) f[i]=f[j]+1; max=0; for (i=1;i<=n;++i) if (f[i]>max) max=f[i]; printf("%d\n",max); } printf("*\n"); //system("pause"); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator