Codeforces 474E Pillars (on the importance of data)

Source: Internet
Author: User

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)

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: 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.