1 条题解
-
0
C :
# include<stdio.h> int main() { int n,i,a[100005],dp[100005],j; while(scanf("%d",&n)!=EOF) { int max=0; for(i=0; i<n; i++) { scanf("%d",&a[i]); dp[i]=1; } for(i=0; i<n; i++) { for(j=i+1; j<n; j++) { if(a[j]>a[i]&&dp[j]<dp[i]+1) dp[j]=dp[i]+1; } } for(i=0; i<n; i++) if(max<dp[i]) max=dp[i]; printf("%d\n",max); } return 0; }
C++ :
#include<cstdio> #include<algorithm> using namespace std; const int MAX=100100; int num[MAX],top=0; int main() { int n; while(~scanf("%d",&n)) { scanf("%d",&num[0]); top=1; for(int i=1;i!=n;i++) { scanf("%d",&num[i]); int * p=lower_bound(num,num+top,num[i]); if(p-num==top) ++top; *p=num[i]; } printf("%d\n",top); } }
- 1
信息
- ID
- 778
- 时间
- 1000ms
- 内存
- 64MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者