[Bzoj 1270] [BeijingWc2008] Leitao's Kitten

Source: Internet
Author: User

Title Link: http://www.lydsy.com:808/JudgeOnline/problem.php?id=1270

See the PKU on the surface of the dormitory, and let me miss the July in the Pku class of the happy time ...

This may be the WC to send a sub-problem, relatively simple motion rules, but also very clever. The maximum number of persimmons that the kitten obtains at height I, F2[i] indicates the maximum number of persimmons that the kitten obtains on the first pillar of the f1[i at the current height.

Then the height from high to low traversal, maintenance F1, F2 can.

#include <iostream> #include <stdio.h> #include <stdlib.h> #include <string.h> #include < Algorithm> #define MAXN 5050using namespace Std;int map[maxn][maxn];int F1[MAXN],F2[MAXN]; f1[i]= height is I, the cat gets the maximum number of Persimmon, f2[i]= the current height of the cat in the first column on the number of persimmons to get the maximum value of int main () {    int n,h,d,ni,t;    scanf ("%d%d%d", &n,&h,&d);    for (int i=1;i<=n;i++)    {        scanf ("%d", &ni);        for (int j=1;j<=ni;j++)        {            scanf ("%d", &t);            map[i][t]++;        }    }    for (int i=h;i>=1;i--)    {        t=i+d;        if (t<=h) t=f1[i+d]; If the cat jumps before, then the maximum number of Persimmon that the cat gets on the previous height is T        else t=0;        for (int j=1;j<=n;j++)        {            F2[j]=max (f2[j],t) +map[j][i];            F1[i]=max (F1[i],f2[j]);        }    }    printf ("%d\n", f1[1]);    return 0;}



[Bzoj 1270][beijingwc2008] Leitao kitten

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.