bzoj 3384: [Usaco2004 Nov]Apple Catching 接苹果
双倍经验题。。。 -->1750
dp!!
3384: [Usaco2004 Nov]Apple Catching 接苹果
Time Limit: 1 Sec Memory Limit: 128 MB
Submit: 61 Solved: 52
[Submit][Status][Discuss]
Description
Input
Output
Sample Input
2
1
1
2
2
1
1
Sample Output
HINT
7分钟内共掉落7个苹果一一第1个从第2棵树上掉落,接下来的2个苹果从第1棵树上掉落,再接下来的2个从第2棵树上掉落,最后2个从第1棵树上掉落. 贝茜不移动直到接到从第1棵树上掉落的两个苹果,然后移动到第2棵树下,直到接到从第2棵
树上掉落的两个苹果,最后移动到第1棵树下,接住最后两个从第1棵树上掉落的苹果.这样贝茜共接住6个苹果.
Source
Gold
#include<cstdio>
int max(int a,int b){return a>b?a:b;}
int t,w,dp[][][],n[],ans;
int main()
{
scanf("%d%d",&t,&w);
for(int i=;i<=t;i++) scanf("%d",&n[i]);
for(int i=;i<=t;i++)
{
dp[i][][]=dp[i-][][]+(n[i]==);
dp[i][][]=dp[i-][][]+(n[i]==);
for(int j=;j<=w;j++)
{
dp[i][j][]=max(dp[i-][j-][],dp[i-][j][])+(n[i]==);
dp[i][j][]=max(dp[i-][j-][],dp[i-][j][])+(n[i]==);
ans=max(ans,max(dp[i][j][],dp[i][j][]));
}
}
printf("%d",ans);
}
bzoj 3384: [Usaco2004 Nov]Apple Catching 接苹果的更多相关文章
- BZOJ 3384: [Usaco2004 Nov]Apple Catching 接苹果( dp )
dp dp( x , k ) = max( dp( x - 1 , k - 1 ) + *** , dp( x - 1 , k ) + *** ) *** = 0 or 1 ,根据情况 (BZOJ 1 ...
- 3384/1750: [Usaco2004 Nov]Apple Catching 接苹果
3384/1750: [Usaco2004 Nov]Apple Catching 接苹果 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 18 Solv ...
- bzoj3384[Usaco2004 Nov]Apple Catching 接苹果*&&bzoj1750[Usaco2005 qua]Apple Catching*
bzoj3384[Usaco2004 Nov]Apple Catching 接苹果 bzoj1750[Usaco2005 qua]Apple Catching 题意: 两棵树,每分钟会从其中一棵树上掉 ...
- P3384: [Usaco2004 Nov]Apple Catching 接苹果
一道DP题, f[i,j,k] 表示 第 k 时刻 由 1 位置 变换 j 次 到达 当前 i 棵树 注意也要维护 变换 0 次的情况. var i,j,k,t,w,now:longint; tree ...
- BZOJ 3385: [Usaco2004 Nov]Lake Counting 数池塘
题目 3385: [Usaco2004 Nov]Lake Counting 数池塘 Time Limit: 1 Sec Memory Limit: 128 MB Description 农夫 ...
- Apple Catching(POJ 2385)
Apple Catching Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9978 Accepted: 4839 De ...
- Apple Catching(dp)
Apple Catching Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9831 Accepted: 4779 De ...
- POJ2385——Apple Catching
$Apple~Catching$ Time Limit: 1000MS Memory Limit: 6553 ...
- 【POJ】2385 Apple Catching(dp)
Apple Catching Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 13447 Accepted: 6549 D ...
随机推荐
- cart回归树算法过程
回归树:使用平方误差最小准则 训练集为:D={(x1,y1), (x2,y2), …, (xn,yn)}. 输出Y为连续变量,将输入划分为M个区域,分别为R1,R2,…,RM,每个区域的输出值分别为: ...
- python中BeautifulSoup模块
BeautifulSoup模块是干嘛的? 答:通过html标签去快速匹配标签中的内容.效率相对比正则会好的多.效率跟xpath模块应该差不多. 一:解析器: BeautifulSoup(html,&q ...
- github删除文件夹
git rm -rf dirgit add .git commit -m 'remove dir'git push origin master //dir是要删除的文件夹路径
- python基础===创建大量对象是节省内存方法
问题: 你的程序要创建大量(可能上百万) 的对象,导致占用很大的内存. 解决方案: 对于主要是用来当成简单的数据结构的类而言,你可以通过给类添加__slots__属性来极大的减少实例所占的内存.比如: ...
- tcp 在调用connect失败后要不要重新socket
tcp 在调用connect失败后要不要重新socket http://blog.csdn.net/occupy8/article/details/48253251
- 【uva11248】网络扩容
网络流裸题. 求完最大流之后保留残余容量信息,依次将已经加入最小割的弧变成c再跑,记录下即可. #include<bits/stdc++.h> #define N 20005 #defin ...
- 写微信API所遇到的问题
1.接口还没出来之前. 根据微信网页版的页面,自己做了页面,分成了两个页面,一个是登录之后的,一个是登录之前的.后来接口出来之后我师兄说要做成只有一个页面时,我就有点吓到了,想想都觉得难,后来用了JQ ...
- 几条学习python的建议
熟悉python语言, 以及学会python的编码方式. 熟悉python库, 遇到开发任务的时候知道如何去找对应的模块. 知道如何查找和获取第三方的python库, 以应付开发任务. 学习步骤 安装 ...
- Leetcode 之Wildcard Matching(32)
跟上题类似,主要考虑‘*’的匹配问题.如果遇到‘*’,则跳过继续匹配,如果不匹配,则s++,重新扫描. bool isMatch2(const char *s, const char *p) { if ...
- LeetCode218. The Skyline Problem
https://leetcode.com/problems/the-skyline-problem/description/ A city's skyline is the outer contour ...