[DP] BZOJ 1270 [BeijingWc2008]雷涛的小猫
2016-05-29 21:34
337 查看
水题
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;
inline char nc(){
static char buf[100000],*p1=buf,*p2=buf;
if (p1==p2) { p2=(p1=buf)+fread(buf,1,100000,stdin); if (p1==p2) return EOF; }
return *p1++;
}
inline void read(int &x){
char c=nc(),b=1;
for (;!(c>='0' && c<='9');c=nc()) if (c=='-') b=-1;
for (x=0;c>='0' && c<='9';x=x*10+c-'0',c=nc()); x*=b;
}
const int N=5005;
int n,d,h;
int cnt
;
int f
,g
;
int main()
{
int x,y;
read(n); read(h); read(d);
for (int i=1;i<=n;i++)
{
read(x);
for (int j=1;j<=x;j++)
read(y),cnt[i][y]++;
}
for (int i=h;i;i--)
{
int tmp=i+d<=h?f[i+d]:0;
for (int j=1;j<=n;j++)
g[j]=max(g[j],tmp)+cnt[j][i],f[i]=max(f[i],g[j]);
}
printf("%d\n",f[1]);
return 0;
}
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;
inline char nc(){
static char buf[100000],*p1=buf,*p2=buf;
if (p1==p2) { p2=(p1=buf)+fread(buf,1,100000,stdin); if (p1==p2) return EOF; }
return *p1++;
}
inline void read(int &x){
char c=nc(),b=1;
for (;!(c>='0' && c<='9');c=nc()) if (c=='-') b=-1;
for (x=0;c>='0' && c<='9';x=x*10+c-'0',c=nc()); x*=b;
}
const int N=5005;
int n,d,h;
int cnt
;
int f
,g
;
int main()
{
int x,y;
read(n); read(h); read(d);
for (int i=1;i<=n;i++)
{
read(x);
for (int j=1;j<=x;j++)
read(y),cnt[i][y]++;
}
for (int i=h;i;i--)
{
int tmp=i+d<=h?f[i+d]:0;
for (int j=1;j<=n;j++)
g[j]=max(g[j],tmp)+cnt[j][i],f[i]=max(f[i],g[j]);
}
printf("%d\n",f[1]);
return 0;
}
相关文章推荐
- HttpClient get请求在HttpResponse中无法获得Location的问题
- 循环
- 天梯匹配系统 - 简单实现
- [平衡树动态维护凸包] BZOJ 2300 [HAOI2011]防线修建
- hdu 4607(树的直径)
- 学习进度条13
- C语言编程经验总结
- 关于在配置hexo中遇到的问题
- 看了下微软更新的Win10系统,特地开了个UWP目录,与大家交流UWP开发
- 寻找数组中的众数
- E: Sub-process /usr/bin/dpkg returned an error code (1) 出错解决方案
- 1008 Problem H
- 易生活(三)-APP—ninegridview源码阅读
- 模块
- 根文件系统制作
- [2015-11-04 21:42:47 - UIWidgetTest] res\drawable-hdpi-v4\Lighthouse.png: Invalid file name: must co
- bzoj1014火星人
- [主席树优化建图 最小割] BZOJ 3218 a + b Problem
- POJ 2376 Cleaning Shifts (贪心,区间覆盖)
- 项目第三周总结