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 ...
随机推荐
- SQL Workbench/J
最近测试segment, 使用了一个新的DB--SQL Workbench/J, 参考文档:http://docs.aws.amazon.com/redshift/latest/mgmt/connec ...
- python中的binascii模块
binascii模块拿来干嘛的? 答:进制转换xxoo #!/usr/bin/env python # encoding:utf-8 # by i3ekr import binascii s = &q ...
- sublime3插件安装及报错处理
ctrl+shift+p调用出窗口:输入install package,然后输入想安装的插件. 有些用户安装的可能是国内破解版的,我的就是,然后install package报错: Package C ...
- Laravel 5.2 数据库迁移和数据填充
一.数据库迁移 Laravel 的数据库迁移提供了对数据库.表.字段.索引的一系列相关操作.下面以创建友情链接表为例. 1. 创建迁移 使用 Artisan 命令 php artisan make: ...
- Lodash使用示例(比较全)
<html> <head> <meta name="viewport" content="width=device-width" ...
- C# 读写XML文件示例
using System; using System.Collections.Generic; using System.Text; using System.Configuration; using ...
- 构造函数、原型对象prototype、实例、隐式原型__proto__的理解
(欢迎一起探讨,如果有什么地方写的不准确或是不正确也欢迎大家指出来~) PS: 内容中的__proto__可能会被markdown语法导致显示为proto. 建议将构造函数中的方法都定义到构造函数的原 ...
- poj 1330(初探LCA)
Nearest Common Ancestors Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 23795 Accept ...
- jquery实现页面加载时删除特定class 的div内前三个字符
jQuery(document).ready(function(){ jQuery("div.groupheader").each(function(){ $(thi ...
- WCF+Windows2008&&sqlserver2008
这些在我的文件和云盘当中也可以在csdn中查找