P2690 接苹果
f[i][j][k]表示
i=1或2,表示j时刻cow在哪棵树下
j表示时刻
k表示转移了k次
如果当前第1棵树落苹果
f[1][t][left]=max(f[1][t-1][left],f[2][t-1][left-1])+1;
如果当前第2棵树落苹果
f[2][t][left]=max(f[2][t-1][left],f[1][t-1][left-1])+1;

 #include<iostream>
#include<cstdio>
#include<queue>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<cstring>
#define inf 2147483647
#define For(i,a,b) for(register int i=a;i<=b;i++)
#define p(a) putchar(a)
#define g() getchar()
//by war
//2017.10.18
using namespace std;
int n;
int x;
int w;
int f[][][];
int ans;
void in(int &x)
{
int y=;
char c=g();x=;
while(c<''||c>'')
{
if(c=='-')
y=-;
c=g();
}
while(c<=''&&c>='')x=x*+c-'',c=g();
x*=y;
}
void o(int x)
{
if(x<)
{
p('-');
x=-x;
}
if(x>)o(x/);
p(x%+'');
} void zy(int t)
{
f[][t][]++;
for(int left=;left<=w;left+=)
f[][t][left]=max(f[][t-][left],f[][t-][left-])+;
} void yz(int t)
{
for(int left=;left<=w;left+=)
f[][t][left]=max(f[][t-][left],f[][t-][left-])+;
} int main()
{
in(n),in(w);
For(t,,n)
{
for(int left=;left<=w;left+=)
f[][t][left]=f[][t-][left];
for(int left=;left<=w;left+=)
f[][t][left]=f[][t-][left];
in(x);
if(x==)
zy(t);
else
yz(t);
}
for(int i=;i<=w;i+=)
ans=max(ans,f[][n][i]);
for(int i=;i<=w;i+=)
ans=max(ans,f[][n][i]);
o(ans);
return ;
}

最新文章

  1. BZOJ1103[POI2007]大都市meg 题解
  2. Using 1.7 requires compiling with Android 4.4 (KitKat); currently using API 10
  3. Java Timer 定时器的使用
  4. Git学习01 --git add, git commit , git log ,git status, git reset --hard, head
  5. OC与Swift桥接问题
  6. 在JS中使用COM组件的方法
  7. Windows 系统下安装 dig 命令
  8. Xamarin.Android 使用AsyncTask提示上传动态
  9. js实现在当前页面搜索高亮显示字的方法
  10. 在Fragment中保存WebView状态
  11. mybatis查询结果和接收的不一样
  12. Java之CountDownLatch使用
  13. 【转】Loadrunder场景设计篇——添加windows Resource计数器和指标说明
  14. The YubiKey -- COMPARISON OF VERSIONS
  15. 获得自己电脑的SSH公匙
  16. tomcat安装图文教程
  17. django drf GenericAPIView和ListAPIView
  18. unity3d之控制人物转向移动并播放动画
  19. java生成jar包
  20. 浅谈箭头函数和setTimeout中的this

热门文章

  1. 9:@RequestMapping 用法详解之地址映射
  2. codeblocks编译器
  3. [转]Robotium环境搭建中的Errors running builder &#39;Android Resource Manag
  4. python 基础数据类型之list
  5. bzoj千题计划232:bzoj4727: [POI2017]Turysta
  6. bzoj千题计划206:bzoj1076: [SCOI2008]奖励关
  7. B-树(B+树) 学习总结
  8. Sublime Text 2 绿色汉化版 x64
  9. js数组方法forEach,map,filter,every,some实现
  10. 如何将java项目转化为web项目