Battle Ships(复习泛化物品**)
Time Limit: 2 Seconds Memory Limit: 65536 KB
Battle Ships is a new game which is similar to Star Craft. In this game, the enemy builds a defense tower, which has L longevity. The player has a military factory, which can produce N kinds of battle ships. The factory takes ti seconds to produce the i-th battle ship and this battle ship can make the tower loss li longevity every second when it has been produced. If the longevity of the tower lower than or equal to 0, the player wins. Notice that at each time, the factory can choose only one kind of battle ships to produce or do nothing. And producing more than one battle ships of the same kind is acceptable.
Your job is to find out the minimum time the player should spend to win the game.
Input
There are multiple test cases.
The first line of each case contains two
integers N(1 ≤ N ≤ 30) and L(1 ≤ L ≤
330), N is the number of the kinds of Battle Ships, L is
the longevity of the Defense Tower. Then the following N lines, each
line contains two integers t i(1 ≤ t
i ≤ 20) and li(1 ≤
li ≤ 330) indicating the produce time and the lethality of
the i-th kind Battle Ships.
Output
Output one line for each test case. An integer indicating the minimum time
the player should spend to win the game.
Sample Input
1 1
1 1
2 10
1 1
2 5
3 100
1 10
3 20
10 100
Sample Output
2
4
5
Author: FU, Yujun
Contest: ZOJ Monthly, July
2012
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int f[],protim[],fi[];
int n,l,i,j;
int main()
{
while(scanf("%d%d",&n,&l)!=EOF)
{
memset(f,,sizeof(f));
for(i=;i<=n;i++)
scanf("%d%d",&protim[i],&fi[i]);
for(i=;i<=l;i++)
for(j=;j<=n;j++)
f[i+protim[j]]=max(f[i+protim[j]],f[i]+i*fi[j]);
for( i=;i<=;i++)
if(f[i]>=l)break;
printf("%d\n",i);
}
return ;
}
Battle Ships(复习泛化物品**)的更多相关文章
- Codeforces 567D One-Dimensional Battle Ships
传送门 D. One-Dimensional Battle Ships time limit per test 1 second memory limit per test 256 megabytes ...
- Codeforces Round #Pi (Div. 2) D. One-Dimensional Battle Ships set乱搞
D. One-Dimensional Battle ShipsTime Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/con ...
- HDU5093——Battle ships(最大二分匹配)(2014上海邀请赛重现)
Battle ships Problem DescriptionDear contestant, now you are an excellent navy commander, who is res ...
- Codeforces Round #Pi (Div. 2) D. One-Dimensional Battle Ships set区间分解
D. One-Dimensional Battle ShipsTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/co ...
- [ZOJ 3623] Battle Ships
Battle Ships Time Limit: 2 Seconds Memory Limit: 65536 KB Battle Ships is a new game which is s ...
- HDOJ 5093 Battle ships 二分图匹配
二分图匹配: 分别按行和列把图展开.hungary二分图匹配. ... 例子: 4 4 *ooo o### **#* ooo* 按行展开. .. . *ooo o#oo oo#o ooo# **#o ...
- 【泛化物品】【HDU1712】【ACboy needs your help】
ACboy needs your help Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Ot ...
- Battle ships(二分图,建图,好题)
Battle ships Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Tot ...
- STL(set_pair)运用 CF#Pi D. One-Dimensional Battle Ships
D. One-Dimensional Battle Ships time limit per test 1 second memory limit per test 256 megabytes inp ...
随机推荐
- 使用TypeDescriptor给类动态添加Attribute【转】
源文 : http://www.cnblogs.com/bicker/p/3326763.html 给类动态添加Attribute一直是我想要解决的问题,从msdn里找了很久,到Stack Overf ...
- 从SDCard获取的图片按分辨率处理的方法
前段时间公司开发的Launcher要做主题切换的功能,但切换主题时须要从sdcard中获取要切换的图片资源,拿到后图片的大小不正常. 后来查找原因是:系统对不同分辨率拿到的图片资源会自己主动的做转化, ...
- pyquery库的使用
pyquery标签选择 获取了所有的img标签(css选择器,你也可以换成不同的class和id) import requests import re from pyquery import PyQu ...
- 【Python】输出程序运行的百分比
对于一些大型的Python程序.我们须要在命令行输出其百分比,显得更加友好,以免被人误会程序陷入死循环.假死的窗口. 关键是利用到不换行的输出符\r,\r的输出.将直接覆盖掉此行的内容. 比方例如以下 ...
- 搭建windows下的odoo开发环境
odoo运行环境的必须要要求是 python环境 postgreSQL数据 数据库可以安装在别的机器上,比如服务器:当然对于开发环境,通常,数据库与代码调试安装在同一台机器上. 首先安装 postgr ...
- Oracle 【to_number】【instr】
需求:对一个包含数字的字符串排序 search后参考了 http://www.cnblogs.com/m-cnblogs/archive/2012/03/30/2425938.html 截屏: (用 ...
- css实现弹出窗体始终垂直水平居中
<!DOCTYPE html><html> <head> <meta charset=" utf-8"> <meta name ...
- ipython notebook 如何打开.ipynb文件?
标签: pythontensorflow 2017-03-29 14:17 235人阅读 评论(0) 收藏 举报 分类: TensorFlow(13) 转自:https://www.zhihu.c ...
- c# CacheManager 缓存管理
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- MySQL 更新和删除
更新和删除的操作SQL语句比較简单,只是要注意使用UPDATE的时候.要注意WEHER条件的限制,以下的语句是仅仅更新id为10005的email地址,假设不加WHERE语句限制,那么将表中全部的em ...