P2690 接苹果
2024-09-30 21:52:29
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 ;
}
最新文章
- BZOJ1103[POI2007]大都市meg 题解
- Using 1.7 requires compiling with Android 4.4 (KitKat); currently using API 10
- Java Timer 定时器的使用
- Git学习01 --git add, git commit , git log ,git status, git reset --hard, head
- OC与Swift桥接问题
- 在JS中使用COM组件的方法
- Windows 系统下安装 dig 命令
- Xamarin.Android 使用AsyncTask提示上传动态
- js实现在当前页面搜索高亮显示字的方法
- 在Fragment中保存WebView状态
- mybatis查询结果和接收的不一样
- Java之CountDownLatch使用
- 【转】Loadrunder场景设计篇——添加windows Resource计数器和指标说明
- The YubiKey -- COMPARISON OF VERSIONS
- 获得自己电脑的SSH公匙
- tomcat安装图文教程
- django drf GenericAPIView和ListAPIView
- unity3d之控制人物转向移动并播放动画
- java生成jar包
- 浅谈箭头函数和setTimeout中的this
热门文章
- 9:@RequestMapping 用法详解之地址映射
- codeblocks编译器
- [转]Robotium环境搭建中的Errors running builder &#39;Android Resource Manag
- python 基础数据类型之list
- bzoj千题计划232:bzoj4727: [POI2017]Turysta
- bzoj千题计划206:bzoj1076: [SCOI2008]奖励关
- B-树(B+树) 学习总结
- Sublime Text 2 绿色汉化版 x64
- js数组方法forEach,map,filter,every,some实现
- 如何将java项目转化为web项目