Wavio Sequence
Time Limit: 3000MS Memory Limit:0KB 64bit IO Format:%lld &%llu
SubmitStatusPracticeUVA 10534
1#include <stdio.h>2#include <string.h>3#include <algorithm>4 using namespacestd;5 Const intinf=0x3f3f3f3f;6 7 intMain ()8 {9 intN;Ten inta[10005],b[10005]; One intdp1[10005],dp2[10005],num1[10005],num2[10005],num3[10005]; A inti,j,k; - while(SCANF ("%d", &n)! =EOF) - { the for(i=0; i<n;i++) - { -scanf"%d",&a[i]); - } + for(i=0; i<n;i++) - { +dp1[i]=inf; Adp2[i]=inf; at } - - for(i=0; i<n;i++) -b[n-i-1]=A[i]; - - for(i=0; i<n;i++) in { - intLower; toLower=lower_bound (Dp2,dp2+n,a[i])-DP2; +num2[i]=lower+1; -dp2[lower]=A[i]; the *Lower=lower_bound (Dp1,dp1+n,b[i])-DP1; $num3[i]=lower+1;Panax Notoginsengdp1[lower]=B[i]; - } the + for(i=0; i<n;i++) Anum1[n-i-1]=Num3[i]; the + /*For (i=0;i<n;i++) - { $ printf ("%d", Num1[i]); $ }*/ - - intans=1; the for(i=0; i<n;i++) - {Wuyi intMi=min (num1[i],num2[i]); the if(mi>ans) -ans=mi; Wu } -printf"%d\n", ans*2-1); About } $ return 0; -}View Code
UVA 105,343 Wavio Sequence