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)