Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 28189 Accepted Submission(s): 11145
8 389 207 155 300 299 170 158 65
2
#include<cstdio> int dp[30010],a[30010]; int max(int a,int b) { return a>b?a:b; } int main() { int n,i,j; while(scanf("%d",&n)!=EOF) { for(i=0;i<n;++i) scanf("%d",&a[i]); int ans=0; for(i=0;i<n;++i) { dp[i]=1; for(j=0;j<i;++j) { if(a[j]<a[i]) dp[i]=max(dp[i],dp[j]+1); } ans=max(dp[i],ans); } printf("%d\n",ans); } return 0;
#include<cstdio> #include<algorithm> #define INF 0x3f3f3f using namespace std; int dp[30010],a[30010]; int main() { int n,i,j; while(scanf("%d",&n)!=EOF) { for(i=0;i<n;++i) { scanf("%d",&a[i]); dp[i]=INF; } for(i=0;i<n;++i) *lower_bound(dp,dp+n,a[i])=a[i]; printf("%d\n",lower_bound(dp,dp+n,INF)-dp); } return 0; }