HDU 5115 Dire Wolf

Source: Internet
Author: User

HDU 5115 Dire Wolf

I had a question about the last field competition in Beijing. I made a short interval dp yesterday. I suddenly remembered this question. It was very similar and I did it.

At first, just like what I did yesterday, I always thought about how to reverse push. Later I found that this question should be being pushed.

In fact, the positive push and reverse push seem very similar, only one is dp [I] [j], which indicates that I, j, and other wolves are used to eliminate the cost of I-j, one is to eliminate the cost when only I-j is left.

Sum up the similarities between the dp in the interval yesterday and the dp in today's interval. It is found that the cost of the interval dp will change with the passage of time or the change of the dp.

#include
 
  #include#include
  
   using namespace std;const int inf=999999999;int a[205],b[205];int dp[205][205],n;void init(){for(int i=0;i<205;i++){for(int j=0;j<205;j++){dp[i][j]=inf;}}b[n+1]=0;for(int i=1;i<=n;i++) dp[i][i]=a[i]+b[i-1]+b[i+1];for(int i=1;i
   
    

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.