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 |
数据都过,为啥就是wa#include<stdio.h> #include<stdlib.h> struct game { int l; int m; }a[10001]; int cmp(const void *c,const void *d) { return ((struct game *)c)->l - ((struct game *)d)->l; } int dp[10001]; int main() { int n,i,j,max,tmax; while(scanf("%d",&n) && n) { for(i=0;i<n;i++) { scanf("%d%d",&a[i].l,&a[i].m); } qsort(a,n,sizeof(a[0]),cmp); dp[0]=1; for(i=0;i<n;i++) dp[i]=1; for(i=1;i<n;i++) { max=0; for(j=0;j<i;j++) { if(a[i].m>=a[j].m) { if(max<dp[j]) { max=dp[j]; } } } dp[i]=max+1; } tmax=0; for(i=0;i<n;i++) { if(tmax<dp[i]) tmax=dp[i]; } printf("%d\n",tmax); } printf("*\n"); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator