Nico Nico Ni~(完全背包)
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~(完全背包)的更多相关文章
- codeforces 372E. Drawing Circles is Fun
tags:[圆の反演][乘法原理][尺取法]题解:圆の反演:将过O点的圆,映射成不过O的直线,相切的圆反演出来的直线平行.我们将集合S中的点做反演变换:(x,y)->(x/(x^2+y^2), ...
- ROS多机通信计算机网络配置
以实现master和nico的互联共享信息为例 1 查看IP地址 $ifconfig 查看ip地址 可以看到 master的IP为192.168.1.10 nico的IP为192.168.1.103 ...
- android开发 RecyclerView 列表布局
创建一个一行的自定义布局 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns ...
- Randy Pausch’s Last Lecture
he University of Virginia American Studies Program 2002-2003. Randy Pausch ...
- 2020年算法设计竞赛 DP
链接:https://ac.nowcoder.com/acm/contest/3002/I来源:牛客网https://ac.nowcoder.com/acm/contest/3002/I 题目描述 & ...
- 【博客导航】Nico博客导航汇总
摘要 介绍本博客关注的内容大类.任务.工具方法及链接,提供Nico博文导航. 导航汇总 [博客导航]Nico博客导航汇总 [导航]信息检索导航 [导航]Python相关 [导航]读书导航 [导航]FP ...
- Nico Game Studio 3.地图纹理编辑 物体皮肤编辑
完成功能: 1.地图纹理编辑功能. 图层编辑,添加/删除纹理,地图编辑.网格绘制.
- Nico Game Studio 2.设置页面读写 纹理载入与选择
进度十分之慢... 配置读写一样采用之前写的自动绑定的方法: 分享一下代码: SetControl是把数据写到control上的. SetObject是把数据写到对象上 GetData是从控件读取数据 ...
- Nico Game Studio 1.基本UI和地图编辑基础功能
完成了基本界面. 本来想自画UI,但是考虑到工作量较大和美观程度有限,以及工具使用对象是比较初级玩家,处于性价比和最初目的,放弃了自绘.
随机推荐
- 【python】入门学习(一)
主要记录一下与C语言不同的地方和特别需要注意的地方: // 整除 ** 乘方 整数没有长度限制,浮点数有长度限制 复数: >>> 1j*1j (-1+0j) 导入模块: import ...
- 不同版本CUDA编程的问题
1 无法装上CUDA的toolkit 卸载所有的NVIDIA相关的app,包括NVIDIA的显卡驱动,然后重装. 2之前的文件打不开,one or more projects in the solut ...
- gcc创建和使用静态库、动态库
http://www.cnblogs.com/dyllove98/archive/2013/06/25/3155599.html 目录树结构: test/include/hello.h #ifdef ...
- lnmp初步学习知识整理
Linux常用30个命令 1.帮助命令 1) man 就是manual的缩写,用来查看系统中自带的各种参考手册(一般linux系统中自带英文手册)! man 命令名 //查看该命令的介绍 2) 命令名 ...
- Yslow网站性能优化工具
Yslow是一款网站性能优化的插件:
- 按键使用方法(二)------verilog
这里我们要验证一键两用的情况:点击与长击,单击与双击 代码: /********************************Copyright*************************** ...
- 【Python】 用python实现定时数据解析服务(前言)
一.Why do it? 背景:项目里上传上来的数据都是未解析的数据,而且数据量还算挺庞大的,每天上传的数据有5kw左右,如果用数据库自带的作业来解析的话,数据库会造成严重的阻塞.因此打算把数据读到外 ...
- Delphi之DLL知识学习2---静态链接和动态链接
静态连接 静态链接是指Delphi 编译器把要调用的函数和过程编译成可执行代码.函数的代码可存留在应用程序的 .dpr文件或一单元中.当链接用户的应用程序时,这些函数与过程便成为最终的可执行文件的一部 ...
- 【JAVA 其它流对象】
一.PrintStream类. 该流是字节流. public class PrintStream extends FilterOutputStream implements Appendable, C ...
- [LeetCode] Largest Rectangle in Histogram
Given n non-negative integers representing the histogram's bar height where the width of each bar is ...