HDU 5773 The All-Purpose Zero (DP)

Source: Internet
Author: User

Topic Link: Click to open the link

Ideas:

First of all: we have to use all 0 is sure not to lose.

Next: We will find the remaining non-0 number of LIS, but these 0 may not be all inserted in the LIS, it is bound to be in the LIS out some number. A very simple way, we subtract each number from the number of 0 in front of him, so that the equivalent of 0 to leave the space, because it is all reduced, the relative size is constant.

See the code for details:

#include <cstdio> #include <cstring> #include <algorithm> #include <iostream> #include < string> #include <vector> #include <stack> #include <bitset> #include <cstdlib> #include < cmath> #include <set> #include <list> #include <deque> #include <map> #include <queue># Define MAX (a) > (b)? ( A):(B) #define MIN (a) < (b) ( A):(B)) using namespace Std;typedef long long ll;typedef long double ld;const double eps = 1e-6;const double PI = ACOs (-1); const INT mod = 1e9 + 7;const int INF = 0x3f3f3f3f;const int seed = 131;const ll INF64 = ll (1e18); const int MAXN = 1e5 + 1    0;int N, M, D[MAXN], G[MAXN], a[maxn], Kase = 0;int main () {int T; scanf ("%d", &t);        while (t--) {scanf ("%d", &n);            for (int i = 1; I <= n; i++) {g[i] = INF;        scanf ("%d", &a[i]);        } int num = 0, ans = 0;           for (int i = 1; I <= n; i++) {if (a[i] = = 0) {     num++;            Continue            } a[i]-= num;            int k = 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", ++kase, Ans+num); } return 0;}



HDU 5773 The All-Purpose Zero (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.