传送门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
 
【题目大意】有l滴血,你有n个战舰,生产每个战舰需要时间,生产后每秒攻击i点血,求耗完l滴血的最少时间。
【code】
#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(复习泛化物品**)的更多相关文章

  1. Codeforces 567D One-Dimensional Battle Ships

    传送门 D. One-Dimensional Battle Ships time limit per test 1 second memory limit per test 256 megabytes ...

  2. 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 ...

  3. HDU5093——Battle ships(最大二分匹配)(2014上海邀请赛重现)

    Battle ships Problem DescriptionDear contestant, now you are an excellent navy commander, who is res ...

  4. 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 ...

  5. [ZOJ 3623] Battle Ships

    Battle Ships Time Limit: 2 Seconds      Memory Limit: 65536 KB Battle Ships is a new game which is s ...

  6. HDOJ 5093 Battle ships 二分图匹配

    二分图匹配: 分别按行和列把图展开.hungary二分图匹配. ... 例子: 4 4 *ooo o### **#* ooo* 按行展开. .. . *ooo o#oo oo#o ooo# **#o ...

  7. 【泛化物品】【HDU1712】【ACboy needs your help】

    ACboy needs your help Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Ot ...

  8. Battle ships(二分图,建图,好题)

    Battle ships Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Tot ...

  9. 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 ...

随机推荐

  1. 设置NSZombieEnabled和MallocStackLogging

    在XCode.4以上版本号中,设置NSZombieEnabled和MallocStackLogging 1.点击XCode的Product菜单.选择Edit Scheme...选项 2.选择左側的Ru ...

  2. android wifi state and wifi ap state

    /** * Wi-Fi is currently being disabled. The state will change to {@link #WIFI_STATE_DISABLED} if * ...

  3. 客户端svn出现authorization failed异常

    原文:https://blog.csdn.net/big1989wmf/article/details/70144470 发现,原来是 服务端上面 svnserve 这个进程没有启动起来 然后,再试一 ...

  4. Cursor类用法:

      Cursor类用法:   http://www.2cto.com/kf/201109/103163.html   Ctrl+Shift+G 查找类.方法和属性的引用.这是一个非常实用的快捷键,例如 ...

  5. Qt5的插件机制(6)--开发Qt插件时几个重要的宏

    怎样开发Qt插件,能够在Qt Assistant 中搜索"Qt Plugins"或"How to Create Qt Plugins",看看那篇manual中的 ...

  6. Ubuntu14下Hadoop开发&lt;2&gt; 编译64位Hadoop2.4

    Hadoop官方站点仅仅提供了32位的Hadoop包.我装的是64位的系统.自然无法使用,会报错误,导致的结果是无法启动hadoop libhadoop.so.1.0.0 which might ha ...

  7. kubernetes之初始容器(init container)

    系列目录 理解初始容器 一个pod里可以运行多个容器,它也可以运行一个或者多个初始容器,初始容器先于应用容器运行,除了以下两点外,初始容器和普通容器没有什么两样: 它们总是run to complet ...

  8. python 修饰符(转载)

    首先一个修饰符的实例: #!/usr/bin/env python def run(fn): def do_hello(): print "begin..." fn() print ...

  9. 流迭代器 + 算法灵活控制IO流

    前言 标准算法配合迭代器使用太美妙了,使我们对容器(数据)的处理更加得心应手.那么,能不能对IO流也使用标准算法呢?有人认为不能,他们说因为IO流不是容器,没有迭代器,故无法使用标准算法.他们错了,错 ...

  10. SDWebImage学习

    SDWebImage学习 SDWebImage版本是:'4.2.2' SDWebImage是iOS开发中常用的图片加载的库,能下载并缓存图片.这次就着重介绍SDWebImage的特色功能:下载与缓存. ...