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 ...
随机推荐
- C# 操作摄像头
如有雷同,不胜荣幸,若转载,请注明 这个是大众普通方法,鉴于有网友和朋友问相同的问题.在这里将我的拙劣的代码关键部分贴出来.以便帮助很多其它的朋友们,不足之处甚多,我能够学习,交流,请教阁下 废话到此 ...
- Head First Python 学习笔记-Chapter3:文件读取和异常处理
第三章中主要介绍了简单的文件读取和简单的异常处理操作. 首先建立文件文件夹:HeadFirstPython\chapter3,在Head First Pythong官方站点下载须要使用的文件:sket ...
- iOS UI08_tableView省市区字典数组
北京 1 北京市 1 西城区 1 东城区 2 崇文区 3 宣武区 4 朝阳区 5 丰台区 6 石景山区 7 海淀区 8 门头沟区 9 房山区 10 通州区 11 顺义区 12 昌平区 13 大兴区 1 ...
- 【Scala类型系统】自身类型(self type)引用
定义 特质能够要求混入它的类扩展自还有一个类型,可是当使用自身类型(self type)的声明来定义特质时(this: ClassName =>).这种特质仅仅能被混入给定类型的子类其中. 如果 ...
- odoo费用报销流程
- c#打包文件解压缩 C#中使用委托、接口、匿名方法、泛型委托实现加减乘除算法 一个简单例子理解C#的协变和逆变 对于过长字符串的大小比对
首先要引用一下类库:using Ionic.Zip;这个类库可以到网上下载. 下面对类库使用的封装方法: 得到指定的输入流的ZIP压缩流对象 /// <summary> /// 得到指定的 ...
- 最新研发的基于Java的高速开发平台
可自我扩展的智能开发平台 在开发平台设计过程中,联科研发部一開始就希望能研发一套智能开发机制能自己开发自己的平台-即一个能自我修复和自我扩展的开发平台.这个开发平台不但能开发其它应用还能不 ...
- Django-admin导出到表格
class AdminReport(admin.ModelAdmin): actions = ["saveexecl"] # 自定义的action(导出到excel表格) list ...
- caffe搭建--缺少 skimage-缺少 google.protobuf.internal.-caffe搭建--ipython--ubuntu16.04+ caffe+ ipython
mkdir build && cd build cmake .. make pycaffe -j4 sudo vim /etc/profile---- export PYTHONPAT ...
- undefined reference to libiconv_open ext/iconv/.libs/iconv.o by install phpsource
错误信息:ext/iconv/.libs/iconv.o(.text+0x30e2): In function `php_iconv_stream_filter_factory_create':/ho ...