传送门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. Controller 层实现

    一.实验介绍 1.1 实验内容 本节课程主要利用 Spring MVC 框架实现 Controller 层以及一些辅助类的实现. 1.2 实验知识点 Spring MVC 框架 1.3 实验环境 JD ...

  2. Mysql5.6审计功能

    1. 前言         为了安全和操作的可追溯性考虑,越来越多的公司增加了审计功能.mysql5.5推出了相关的审计功能,到5.6.20功能进一步完好.算是勉强可用了.尽管细粒度方面做的不是太好. ...

  3. PPAPI插件的动态创建、改动、删除

    一旦你完毕了PPAPI插件的开发,实际使用时可能会有下列需求: 动态创建PPAPI插件 删除PPAPI插件 改变PPAPI插件的尺寸 实现起来非常easy,从JS里直接訪问DOM(BOM)就可以.以下 ...

  4. LeetCode – Copy List with Random Pointer

    A linked list is given such that each node contains an additional random pointer which could point t ...

  5. iOS学习笔记12-网络(一)NSURLConnection

    一.网络请求 在网络开发中.须要了解一些经常使用的请求方法: GET请求:get是获取数据的意思,数据以明文在URL中传递,受限于URL长度,所以数据传输量比較小. POST请求:post是向serv ...

  6. SpringMVC:JSON

    @ResponseBody params="json":访问我这个方法的时候一定要有参数名为json 返回值Userjackson-all-1.9.0.jar @RequestMa ...

  7. mvc用UpdateModel报错

    项目中使用UpdateModel时报错:未能更新类型“XXXXXX”的模型. 原因如下:表单Post时,有的参数为空,如a=1&b=2&=3.

  8. TCP/IP协议组学习笔记

    TCP/IP协议族学习笔记: 一.基础概念: (1)TCP(Transmission Control Protocol) 传输控制协议. (2)IP(Internet Protocol)网际协议.IP ...

  9. 根据百度地图API获取指定地点的经纬度

    做项目时,遇到对地点获取地图中对应的经纬度,作一下笔记,以备以后直接使用 package com.hpzx.data; import java.io.BufferedReader; import ja ...

  10. thttpd源代码解析 定时器模块

    thttpd源代码解析 定时器模块 thttpd是很轻量级的httpserver,可运行文件仅50kB.名称中的第一个t表示tiny, turbo, 或throttling 与lighttpd.mem ...