HDU 1176 DP Number tower problem

Source: Internet
Author: User

Hey, at first I didn't see starting from 5 ....

Later wrote, using the queue forward, record the node can reach,p[i+1][j] = max (P[i][j],max (p[i][j-1],p[i][j+1) )

Well, with the STL Mle, write their own queue and tle, do not know why hmm, like BFS I have never been a ...

Look at the idea of Dicuss, only see a few two words of the tower I understand ...

Can only be said cleverly, the interval reversed to determine I did not think ...

//The problem of the tower/*t=0 5 t=1 456 t=2 34567 t=3 2345678 t=4 123456789 t=5 0123456789A*/#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>#include<cmath>Const intmaxn= 1e5+Ten;using namespacestd;intdp[maxn][ A];intmov[3]={-1,0,1};/*bool Isoverborder (int x) {if (x<0| |    X>10) return true; else return false;}*/voidinit () { for(intI=0; i<maxn;i++){         for(intj=0;j< One; j + +) {Dp[i][j]=0; }    }}intMain () {intN;  while(SCANF ("%d",&N), N) {intt,p; intMaxt =-MAXN;        Init ();  for(intI=0; i<n;i++) {scanf ("%d%d",&p,&t); DP[T][P]+=1; Maxt=Max (maxt,t); }         for(inti=maxt-1; i>=0; i--) {dp[i][0] + = max (dp[i+1][0],dp[i+1][1]);  for(intj=1;j< One; j + +) {Dp[i][j]+ = max (dp[i+1][j],max (dp[i+1][j+1],dp[i+1][j-1])); }} cout<<dp[0][5]<<Endl; }    return 0;}
View Code

HDU 1176 DP Number tower problem

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.