zoukankan      html  css  js  c++  java
  • bzoj1270 [BeijingWc2008]雷涛的小猫

    题目链接

    我真是DP弱者
    想了半天。。。h1[i]记录当前在第i棵树的最大值(滚动数组),h2[i]记录高度在i时的最大值
    这两个数组可以交替更新

     1 #include<algorithm>
     2 #include<iostream>
     3 #include<cstdlib>
     4 #include<cstring>
     5 #include<cstdio>
     6 #include<string>
     7 #include<cmath>
     8 #include<ctime>
     9 #include<queue>
    10 #include<stack>
    11 #include<map>
    12 #include<set>
    13 #define rre(i,r,l) for(int i=(r);i>=(l);i--)
    14 #define re(i,l,r) for(int i=(l);i<=(r);i++)
    15 #define Clear(a,b) memset(a,b,sizeof(a))
    16 #define inout(x) printf("%d",(x))
    17 #define douin(x) scanf("%lf",&x)
    18 #define strin(x) scanf("%s",(x))
    19 #define LLin(x) scanf("%lld",&x)
    20 #define op operator
    21 #define CSC main
    22 typedef unsigned long long ULL;
    23 typedef const int cint;
    24 typedef long long LL;
    25 using namespace std;
    26 void inin(int &ret)
    27 {
    28     ret=0;int f=0;char ch=getchar();
    29     while(ch<'0'||ch>'9'){if(ch=='-')f=1;ch=getchar();}
    30     while(ch>='0'&&ch<='9')ret*=10,ret+=ch-'0',ch=getchar();
    31     ret=f?-ret:ret;
    32 }
    33 int n,a[2020][2020],h,delta,h1[4040],h2[4040];
    34 int main()
    35 {
    36     inin(n),inin(h),inin(delta);
    37     re(i,1,n)
    38     {
    39         int x,t;inin(x);
    40         while(x--)inin(t),a[i][t]++;
    41     }
    42     rre(i,h,1)
    43     {
    44         re(j,1,n)h1[j]=max(h1[j],h2[i+delta])+a[j][i];
    45         re(j,1,n)h2[i]=max(h2[i],h1[j]);
    46     }
    47     printf("%d",h2[1]);
    48      return 0;
    49 }
  • 相关阅读:
    H5 俄罗斯方块Demo
    HTML5 Web Workers
    H5 基于Web Storage 的客户端留言板
    H5 百度一下,你就知道
    H5 71-网易注册界面4
    H5 70-清除浮动方式五
    H5 69-清除浮动方式四
    H5 68-伪元素选择器
    H5 67-清除浮动方式三
    H5 66-清除浮动方式二
  • 原文地址:https://www.cnblogs.com/HugeGun/p/5243509.html