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 |
错在哪了????不知道啊!寻求路过的帮忙错在哪了????不知道啊!寻求路过的帮忙错在哪了????不知道啊!寻求路过的帮忙#include<iostream> using namespace std; int cmp(const void *a,const void *b) { return (*(int *)a-*(int *)b); } int L[1001][1001]; int main() { int i,j; int N,aa[1001],bb[1001]; while(scanf("%d",&N)!=EOF){ memset(aa,0,sizeof(aa)); memset(bb,0,sizeof(bb)); memset(L,0,sizeof(L)); for(i = 0;i < N;i ++){ scanf("%d",&aa[i]); bb[i] = aa[i]; } qsort(bb,N,sizeof(bb[0]),cmp); for(i = 0;i <= N;i++){ L[i][0] = 0; L[0][i] = 0; } for(i = 1;i <= N;i ++) for(j = 1;j <=N;j ++){ if(aa[i]==bb[j]){ L[i][j] = L[i-1][j-1] + 1; } else{ L[i][j] = (L[i][j-1] > L[i-1][j] ? L[i][j-1] : L[i-1][j]); } } printf("%d\n",L[N][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