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 ...
随机推荐
- import学习
一.import as import socket, os, regex模块导入时可以使用 as 关键字来改变模块的引用对象名字: import os as system //当多个引入时 ...
- 【1】记一次破解wifi
当然,使用的依旧是aircrack套件,这次依旧是跑字典,今天,捉到了另一个实验室icephone的wpa握手包,我猜测实验室的wifi一般都跟自己的名字有关,icephone刚好是8位字母,于是我就 ...
- kimbits_USACO
StringsobitsKim Schrijvers Consider an ordered set S of strings of N (1 <= N <= 31) bits. Bits ...
- OWASP SSL 高级审查工具
http://www.linuxidc.com/Linux/2016-03/129164.htm InfoWorld 在部署.运营和保障网络安全领域精选出了年度开源工具获奖者. 最佳开源网络和安全软件 ...
- Centos_Lvm expand capacity without restarting CentOS
Rescan the new disk(/dev/sdb): #ls /sys/class/scsi_host/ host0 host1 host2 [root@db210_13:56:14 /dat ...
- STL之顺序容器 deque 动态数组
deque是一个动态数组,deque与vector非常类似,vector是一个单向开口的连续线性空间,deque则是双向开口的连续线性空间.两者唯一的区别是deque可以在数组的开头和末尾插入和删除数 ...
- 调用手机端硬件功能 汇总(android/ios) Native.js示例汇总
Native.js示例汇总 NJS Native.JS 示例 Native.js虽然强大和开放,但很多web开发者因为不熟悉原生API而难以独立完成.这篇帖子的目的就是汇总各种写好的NJS代码,方便w ...
- input标签获取焦点时文本框内提示信息清空背景颜色发生变化
<input type="text" id="username" onfocus="myFocus(this,'#f4eaf1')" ...
- thinkphp模板常用的方法
thinkphp模板我是看了3.2的文档,对里面的东西过了一遍,然后在写到需要用到模板的东西的时候就有印象,有的能直接回顾,但是有的就可能只知道有这个东西,但是不知道怎么用,所以就重新查手册,这个的话 ...
- django “如何”系列8:如何为模型提供初始化数据
当你第一次配置一个app的时候,有时候使用硬编码的数据去预填充你的数据库是非常有用的.这里有几个你可以让django自动创建这些数据的方法:你可以提供固定格式的初始化数据或者提供通过SQL初始化数据. ...