Bzoj 4300: A great problem

Source: Internet
Author: User

Problem 4300. --Excellent title

4300: Fantastic title time limit:1 Sec Memory limit:128 MB
submit:1597 solved:814
[Submit] [Status] [Discuss] Description given an n-length sequence AI, the longest length of the AI's subsequence bi is satisfied with bi&bi-1!=0 (2<=i<=len).

Input file total 2 rows. The first line includes an integer n. The second line includes n integers, and the first integer represents AI.

Output file has a single row. Includes an integer that represents the longest length of the subsequence bi.

Sample Input3
1 2 3Sample Output2HINT

N<=100000,ai<=2*10^9


Source

by Oxer

[Submit] [Status] [Discuss]

Greedy, using $f[i]$ to denote the longest-oldest sequence length of the ending number I-bit 1.

1 Importjava.util.Arrays;2 ImportJava.util.Scanner;3  4  Public classMain {5      6 Public Static voidMain (String args[]) {7          8Scanner in =NewScanner (system.in);9          Tenintn =in.nextint (); OneintF[] =New int[35]; A           -Arrays.fill (F, 0); -           the for(inti = 1; I <= N; ++i) { -               -intnum = In.nextint (), TMP = 0; -               + for(intj = 0; J <= 30; ++j) -if((Num >> j) & 1) = = 1) +TMP =Math.max (TMP, f[j]); A               at for(intj = 0; J <= 30; ++j) -if((Num >> j) & 1) = = 1) -F[J] = Math.max (F[j], TMP + 1); -           -         } -           inintAns = 0; -           to for(inti = 0; I <= 30; ++i) +Ans =Math.max (ans, f[i]); -           the System.out.println (ans); *           $ in.close ();Panax Notoginseng           -     } the   +}

@Author: Yousiki

Bzoj 4300: good title

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.