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<iostream> #include<cstdio> #include<cstdlib> #include<algorithm> #include<cmath> #include<cstring> #define MAXN 5500 using namespace std; int n,a[MAXN],b[MAXN],c[MAXN],ans; int main() { scanf("%d",&n); for(int i=0;i<n;i++) {scanf("%d",&a[i]);c[i]=1;b[i]=1;} for(int i=1;i<n;i++) { for(int j=i-1;j>=0;j--) { if(a[j]>a[i]) { if (b[j]>=b[i]) {c[i]=c[j];b[i]=b[j]+1;} else if(b[j]==b[i]-1) c[i]+=c[j]; } if(a[i]==a[j]) {if(b[i]==1) c[i]=0; break;} } ans=max(ans,b[i]); } int num=0; for(int i=0;i<n;i++) if(ans==b[i]) num+=c[i]; printf("%d %d",ans,num);while(1); } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator