Time Limit:2000MS  Memory Limit:65535K

Type: Program   Language: Not Limited

Description

Lys plays Love Live game now. You can level up via playing songs and get experiences ei but consume
spirit si. Initially, you have n songs and spirit SP, empty experience. When you get enough experience,
you step in next level, and the experience you got flush to empty and the spirit will be filled full.
What’s more, when you step in next level, the total spirit SP will increase c, means you have c extra
spirit to consume, and required q more experiences to step in next level.
Now give you n songs, and the experience you can get and the spirit you should consume of each song.
The initially spirit SP you have, the first level experience requirement. You can tell how the level
you can step in?

Input

First line has one integer t, the number cases.
For each case, first line, n(1<=n<=10), n songs, SP(1<=SP<=1000), the initial spirit, EP(1<=EP<=100000),
the first level requirement experiences,
c(1<=c<=100), the extra spirit you can get for each level,
q(1<=q<=100), the extra requirement experiences for each level
.
Next n lines, for each line, has two integers, s, e, consume spirit s and get experiences e for
each song.

Output

For each case, print the most level you can get. If the level is larger than 10000, you should only
output 10000.

Sample Input

1
2 10 10 5 6
3 3
4 4

Sample Output

2

Hint

Before playing the song, you have 10 spirit, and require 10 experience to step into next level.
You can play the first song two times and the second song one time, consume 10 spirt, and get 10
experiences, step level 2. And spirt become 15, and require 16 experiences to next level. Then
you can not step into next level with this spirit. 思路:完全背包,每一次在背包容量为sp时,获得的最大价值为mv,当mv大于等于ep时,表示能升级,此时背包容量扩充为 sp + c, 升级条件变为 mv >= (ep + q)
而随着背包容量的扩充,之前的dp[]已经保存了对应状态的最优值,故不必重新dp一遍
 /*
times 108ms
by orc
*/
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
#include <set>
using namespace std ;
int n, sp, ep, c, q ;
int s[], e[] ;
int nsize ;
int dp[] ;
int getans(int cur)
{
int& res = dp[cur] ;
if(res != -) return res ;
res = ;
for(int i = ; i <= n; ++i)
if(cur >= s[i])
res = max(res,getans(cur - s[i]) + e[i]) ;
return res ;
}
int main()
{
#ifdef LOCAL
freopen("in.txt","r",stdin) ;
#endif int t ;
scanf("%d",&t) ;
while(t--)
{
scanf("%d%d%d%d%d",&n,&sp,&ep,&c,&q) ;
for(int i = ; i <= n; ++i) scanf("%d%d",&s[i],&e[i]) ;
int nsize = sp, lev = ;
memset(dp, - ,sizeof dp) ;
while()
{
int now = getans(nsize) ;
// printf("[%d]\n",now) ;
if(now >= ep) {lev++; nsize += c ; ep += q ;} else break ;
if(lev >= ) break ;
}
if(lev >= ) printf("10000\n") ;
else printf("%d\n",lev) ;
} }

Nico Nico Ni~(完全背包)的更多相关文章

  1. codeforces 372E. Drawing Circles is Fun

    tags:[圆の反演][乘法原理][尺取法]题解:圆の反演:将过O点的圆,映射成不过O的直线,相切的圆反演出来的直线平行.我们将集合S中的点做反演变换:(x,y)->(x/(x^2+y^2), ...

  2. ROS多机通信计算机网络配置

    以实现master和nico的互联共享信息为例 1 查看IP地址 $ifconfig 查看ip地址 可以看到 master的IP为192.168.1.10 nico的IP为192.168.1.103 ...

  3. android开发 RecyclerView 列表布局

    创建一个一行的自定义布局 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns ...

  4. Randy Pausch’s Last Lecture

          he University of Virginia American Studies Program 2002-2003.                     Randy Pausch ...

  5. 2020年算法设计竞赛 DP

    链接:https://ac.nowcoder.com/acm/contest/3002/I来源:牛客网https://ac.nowcoder.com/acm/contest/3002/I 题目描述 & ...

  6. 【博客导航】Nico博客导航汇总

    摘要 介绍本博客关注的内容大类.任务.工具方法及链接,提供Nico博文导航. 导航汇总 [博客导航]Nico博客导航汇总 [导航]信息检索导航 [导航]Python相关 [导航]读书导航 [导航]FP ...

  7. Nico Game Studio 3.地图纹理编辑 物体皮肤编辑

    完成功能: 1.地图纹理编辑功能. 图层编辑,添加/删除纹理,地图编辑.网格绘制.

  8. Nico Game Studio 2.设置页面读写 纹理载入与选择

    进度十分之慢... 配置读写一样采用之前写的自动绑定的方法: 分享一下代码: SetControl是把数据写到control上的. SetObject是把数据写到对象上 GetData是从控件读取数据 ...

  9. Nico Game Studio 1.基本UI和地图编辑基础功能

    完成了基本界面. 本来想自画UI,但是考虑到工作量较大和美观程度有限,以及工具使用对象是比较初级玩家,处于性价比和最初目的,放弃了自绘.

随机推荐

  1. 【processing】小代码2

    函数: 绘制直线自由图形: beginShape(), vertex(), endShape() 分别是绘制图形开始,连接图形的节点,绘制结束 endShape(CLOSE)表示闭合图形. 绘制曲线边 ...

  2. 控制器与xib关联(用xib布局控制器)

    IOS Xib使用——为控制器添加Xib文件 Xib文件是一个轻量级的用来描述局部界面的文件,它与StoryBoard类似,都是使用Interface Bulider工具进行编辑.但是StoryBoa ...

  3. 关于jQuery新的事件绑定机制on()的使用技巧

    关于jQuery新的事件绑定机制on()的使用技巧 http://www.jb51.net/article/36064.htm 本篇文章介绍了,关于jQuery新的事件绑定机制on()的使用技巧.需要 ...

  4. 【转】Java高手真经全套书籍分享

    (转自:http://blog.sina.com.cn/s/blog_4ec2a8390101cd1n.html) 中文名: Java高手真经 原名: JAVA开发专家 作者: 刘中兵Java研究室 ...

  5. 4.1 pair类模板

    在学习关联容器之前,首先先要了解一下STL中的pair类模板,因为关联容器的一些成员函数返回值都是pair对象,而且map 和multimap中的元素都是pair对象. 1)pair类模板定义 pai ...

  6. PHP魔术方法在框架中的应用

    class usermodel{ protected $email='user@163.com'; protected $data=array(); public function __set($k, ...

  7. MVC缓存01,使用控制器缓存或数据层缓存

    对一些浏览频次多.数据量大的数据,使用缓存会比较好,而对一些浏览频次低,或内容因用户不同的,不太适合使用缓存.   在控制器层面,MVC为我们提供了OutputCacheAttribute特性:在数据 ...

  8. JavaWeb学习之转发和重定向、会话技术:cookie、session、验证码实例、URLConnection使用(下载网页)(4)

    1.转发和重定向 HttpServletResponse response 转发: RequestDispatcher dispatcher = request.getRequestDispatche ...

  9. 重温WCF之消息契约(MessageContract)(六)

    对于SOAP来说主要由两部分构成Header和Body,他们两个共同构成了SOAP的信封,通常来说Body保存具体的数据内容,Header保存一些上下文信息或关键信息.比如:在一些情况下,具有这样的要 ...

  10. 6-04使用SQL语句更新数据

    修改数据语法: UPDATTE 表名 SET 列名 =更新值 WHERE 更新条件 1:省略WHERE条件的更新: 更新性别: UPDATE  UserInfo SET Gender=1 三行受影响. ...