Bzoj 4300: A great problem (DP)

Source: Internet
Author: User

DP (i) represents the maximum value of the binary I-bit 1 o'clock, then the DP from left to right

------------------------------------------------------------------------

#include <cstdio>#include <cstring>#include <algorithm>using namespace std;#define B (i) (1 << (i))const int MAXN = 100009;const int n = +;int dp[40], N;int main () {memset (DP, 0, sizeof DP);scanf ("%d", &n);for (int i = 0; i < N; i++) {int t = 0, A;scanf ("%d", &a);For (int j = 0; J < N; j + +)if (b (j) & a) T = max (T, Dp[j]);t++;For (int j = 0; J < N; j + +)if (b (j) & A) dp[j] = max (dp[j], t);}printf ("%d\n", *max_element (DP, DP + +));return 0;}

------------------------------------------------------------------------

4300: Good title time limit: 1 Sec Memory Limit: MB
Submit: 274 Solved: 168
[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

For 100% of data, 1<=n<=100000,ai<=10^9.


Source

by Oxer

Bzoj 4300: A great problem (DP)

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.