Time Limit:2000MS  Memory Limit:65535K

Type: Program   Language: Not Limited

Description

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

Input

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

Output

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

Sample Input

  1. 1
  2. 2 10 10 5 6
  3. 3 3
  4. 4 4

Sample Output

  1. 2

Hint

  1. Before playing the song, you have 10 spirit, and require 10 experience to step into next level.
  2. You can play the first song two times and the second song one time, consume 10 spirt, and get 10
  3. experiences, step level 2. And spirt become 15, and require 16 experiences to next level. Then
  4. you can not step into next level with this spirit.
  5.  
  6. 思路:完全背包,每一次在背包容量为sp时,获得的最大价值为mv,当mv大于等于ep时,表示能升级,此时背包容量扩充为 sp + c, 升级条件变为 mv >= (ep + q)
    而随着背包容量的扩充,之前的dp[]已经保存了对应状态的最优值,故不必重新dp一遍
  1. /*
  2. times 108ms
  3. by orc
  4. */
  5. #include <cstdio>
  6. #include <iostream>
  7. #include <cstring>
  8. #include <algorithm>
  9. #include <queue>
  10. #include <set>
  11. using namespace std ;
  12. int n, sp, ep, c, q ;
  13. int s[], e[] ;
  14. int nsize ;
  15. int dp[] ;
  16. int getans(int cur)
  17. {
  18. int& res = dp[cur] ;
  19. if(res != -) return res ;
  20. res = ;
  21. for(int i = ; i <= n; ++i)
  22. if(cur >= s[i])
  23. res = max(res,getans(cur - s[i]) + e[i]) ;
  24. return res ;
  25. }
  26. int main()
  27. {
  28. #ifdef LOCAL
  29. freopen("in.txt","r",stdin) ;
  30. #endif
  31.  
  32. int t ;
  33. scanf("%d",&t) ;
  34. while(t--)
  35. {
  36. scanf("%d%d%d%d%d",&n,&sp,&ep,&c,&q) ;
  37. for(int i = ; i <= n; ++i) scanf("%d%d",&s[i],&e[i]) ;
  38. int nsize = sp, lev = ;
  39. memset(dp, - ,sizeof dp) ;
  40. while()
  41. {
  42. int now = getans(nsize) ;
  43. // printf("[%d]\n",now) ;
  44. if(now >= ep) {lev++; nsize += c ; ep += q ;}
  45.  
  46. else break ;
  47. if(lev >= ) break ;
  48. }
  49. if(lev >= ) printf("10000\n") ;
  50. else printf("%d\n",lev) ;
  51. }
  52.  
  53. }

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. 【CCL】连通区域提取

    根据朋友给的一份原理写的 感觉还挺清楚 #include "cv.h" #include "highgui.h" #include <stdio.h> ...

  2. IIS7.0配置网站时,提示“ISAPI 和 CGI 限制”

    把网站配置到IIS上的时候,访问网站提示如下错误:  

  3. win8访问win7中的共享文件夹 映射网络驱动器

    同一个局域网内,配置好了一台win7(假设计算机名为A)的共享文件夹,设置方法可以参考http://www.doudouxitong.com/guzhang/xitongjiqiao/2014/082 ...

  4. CSS应用给网页元素的几种方式总结

    一.内联式样式表 直接在HTML标签中使用style进行定义样式.如:<p style="color:red;">这里是红色文字</p>. 二.嵌入式样式表 ...

  5. IOS关于录音,播放实现总结

    //音频录制(标准过程5,9更新) 准备:导入AVFoundation框架及头文件 1 设置会话类型,允许播放及录音AVAudioSession *audioSession = [AVAudioSes ...

  6. iPhone:4.7 5.5 4 3.5 对应的各个设备屏幕尺寸对应的像素及App上线信息

    Shared App Information You can access these properties from the App Details page in the App Informat ...

  7. 《C#本质论》读书笔记(14)支持标准查询操作符的集合接口

      14.2.集合初始化器 使用集合初始化器,程序员可以采用和数组相似的方式,在集合的实例化期间用一套初始的成员来构造这个集合. 如果没有集合初始化器,就只有在集合实例化后才能显示添加到集合中--例如 ...

  8. ManageEngine Glossary

    https://www.manageengine.com/products/applications_manager/help/glossary-applications-manager.html#s ...

  9. HTTPS的一些疑问解答

    PHP写的网站怎么用https访问,具体要怎样 这跟用什么语言写的网站没有关系,可以去申请个快速的SSL证书,一年也就几十块. 开启apache server的ssl,自己做个免费的ssl证书或者去申 ...

  10. HTML CSS微信CSS显示一些总结

    微信显示网页是调用腾讯自带的浏览器内核,由于腾讯浏览器内核对css展示效果没有谷歌浏览器好,导致用谷歌浏览器写好的网页,放到微信页面之后,显示的效果就发生变化,所以调整css样式显得那么吃力: 1. ...