Today to do this problem, a look is a very long non-descending series of water, but the data super big, how to do, the whim, because every time and before, then need to push the state from the first state, then there is data comparison of water, perhaps the previous 600 states can be a reasoning to, So straight from his money 600 states pushed over the water
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include < Vector>using namespace Std;typedef long long int ll;const int n=100100;int n,k;ll h[n],sum[n],path[n],ans[n];int Main ( ) {cin>>n>>k;sum[1]=1; int maxl=1;for (int i=1;i<=n;i++) {cin>>h[i];sum[i]=1;for (int j=max (1), i-600) {j<i;j++) {if (ABS (H[j]-h[i]) >=k&&sum[j]+1>sum[i]) {sum[i]=sum[j]+1;path[i]=j;//Next is j}if ( SUM[I]>SUM[MAXL]) {maxl=i;}}} Cout<<sum[maxl]<<endl;int t=path[maxl];int Cnt=0;ans[cnt]=maxl;while (T) {Ans[++cnt]=T; T=PATH[T];} for (int i=cnt;i>=0;i--) {cout<<ans[i]<< "";} return 0;}
Codeforces 474E Pillars (on the importance of data)