HUD 5773 LIS (longest ascent sequence)

Source: Internet
Author: User
Tags cas

For the use of Lower_bound () See: http://blog.csdn.net/niushuai666/article/details/6734403***

#include <iostream>#include<cstdio>#include<cstring>#include<cstdlib>#include<cmath>#include<cctype>#include<queue>#include<vector>#include<algorithm>using namespaceStd;typedefLong LongLL;#defineN 101000#defineINF 0x3f3f3fintA[n], g[n], d[n];intMain () {intT, N, cas=1; scanf ("%d", &u);  while(t--) {scanf ("%d", &N);  for(intI=1; i<=n; i++) {G[i]=INF; scanf ("%d", &A[i]); }        intnum, ans; Num=ans=0;  for(intI=1; i<=n; i++)        {            if(a[i]==0) {num++; Continue; } A[i]-=num;//minus the number of front zeros, so you can tick some numbers and leave enough space for the zero transformation .intK=lower_bound (g+1, g+n+1, A[i])-G; D[i]=K; G[K]=A[i]; Ans=Max (ans, d[i]); } printf ("Case #%d:%d\n", cas++, ans+num); }    return 0;}

HUD 5773 LIS (longest ascent sequence)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.