传送门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
  2. 1 1
  3. 2 10
  4. 1 1
  5. 2 5
  6. 3 100
  7. 1 10
  8. 3 20
  9. 10 100

Sample Output

  1. 2
  2. 4
  3. 5

Author: FU, Yujun
Contest: ZOJ Monthly, July
2012
 
【题目大意】有l滴血,你有n个战舰,生产每个战舰需要时间,生产后每秒攻击i点血,求耗完l滴血的最少时间。
【code】
  1. #include<iostream>
  2. #include<cstdio>
  3. #include<cstring>
  4. using namespace std;
  5. int f[],protim[],fi[];
  6. int n,l,i,j;
  7. int main()
  8. {
  9. while(scanf("%d%d",&n,&l)!=EOF)
  10. {
  11. memset(f,,sizeof(f));
  12. for(i=;i<=n;i++)
  13. scanf("%d%d",&protim[i],&fi[i]);
  14. for(i=;i<=l;i++)
  15. for(j=;j<=n;j++)
  16. f[i+protim[j]]=max(f[i+protim[j]],f[i]+i*fi[j]);
  17. for( i=;i<=;i++)
  18. if(f[i]>=l)break;
  19. printf("%d\n",i);
  20. }
  21. return ;
  22. }

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. HBase 基本操作

    如何添加列族 很简单,跟rdbms一样 直接用alter,但是alter之前必须先disable这个表 ---->disable 'test'                          ...

  2. 转:WebRTC技术及应用2 – NAT穿越技术的使用

    评:webrtc自带的打洞,穿透协议. 转: http://www.unclekevin.org/?p=924 959 views WebRTC技术及应用2 – NAT穿越技术的使用 发表回复 (题图 ...

  3. mybatis表名反射实体

    package com.eshore.wbtimer.executor.service.impl; import com.baomidou.mybatisplus.mapper.EntityWrapp ...

  4. C#中如何让ListView控件点击选中整行

    将Listview控件的FullRowSelect属性置为True,当然Listview的View属性应该是Details. 2017年6月25日17:15:55

  5. CMake - boost - 可运行程序 - 静态库

    CMake - boost 最后更新日期:2014-04-25by kagula 阅读前提:<CMake入门(二)>.Linux的基本操作 环境: Windows 8.1 64bit英文版 ...

  6. hibernate 自动封装

    一.查询全部对象属性的封装则比较简单 Query query = this.getSession().createSQLQuery(queryString).addEntity(pojoClass); ...

  7. 1079. Total Sales of Supply Chain (25)【树+搜索】——PAT (Advanced Level) Practise

    题目信息 1079. Total Sales of Supply Chain (25) 时间限制250 ms 内存限制65536 kB 代码长度限制16000 B A supply chain is ...

  8. centos创建本地yum仓库

    怎样发布自己软件的安装和更新YUM源 在创建之前,我们先了解些相关的内容: yum仓库可以支持三种途径提供给yum在安装的时候下载rpm包 第一种:  ftp服务  ftp:// 第二种:  http ...

  9. matlab2016b -ubuntu 1604 -install- and -trouble -shooting--finally-all is ok!!

    Linux系统下安装matlab2016b 标签: ubuntumatlablinux 2016-09-24 22:11 16203人阅读 评论(22) 收藏 举报 分类: linux 版权声明:本文 ...

  10. PE发送报文

    步骤: 1. 在 action 中使用发送报文,要指定报文在 router 端的交易名称 2. 如果使用 supe.execute(context) 来发送,不需要第一步 3. 配置从网银到 rout ...