题意理解有误导致方程建歪,题意是n种类型的船造成至少L伤害的最小时间,攻击过程是不必同步的

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#define rep(i,j,k) for(register int i=j;i<=k;i++)
#define rrep(i,j,k) for(register int i=j;i>=k;i--)
#define erep(i,u) for(register int i=head[u];~i;i=nxt[i])
#define iin(a) scanf("%d",&a)
#define lin(a) scanf("%lld",&a)
#define din(a) scanf("%lf",&a)
#define s0(a) scanf("%s",a)
#define s1(a) scanf("%s",a+1)
#define print(a) printf("%lld",(ll)a)
#define enter putchar('\n')
#define blank putchar(' ')
#define println(a) printf("%lld\n",(ll)a)
#define IOS ios::sync_with_stdio(0)
using namespace std;
const int maxn = 1e6+11;
const int oo = 0x3f3f3f3f;
const double eps = 1e-7;
typedef long long ll;
ll read(){
ll x=0,f=1;register char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
int n,L,cost[maxn],weight[maxn],tot;
int dp[maxn];
int main(){
while(cin>>n>>L){
rep(i,1,n){
cost[i]=read();
weight[i]=read();
}
memset(dp,0,sizeof dp);
int ans=oo;
//时间为j时能生产船伤害的最大总值
// rep(i,1,n){
// rep(j,cost[i],n*L){
// dp[j]=max(dp[j],dp[j-cost[i]]+weight[i]);
// if(dp[j]==0) continue;
// else ans=min(ans,j+(int)ceil(1.0*L/dp[j]));//这个是必须建好后一起攻击
// }
// }
rep(i,1,n){
rep(j,cost[i],6667){
dp[j]=max(dp[j],dp[j-cost[i]]+(j-cost[i])*weight[i]);//这个是一旦建好船久可以直接攻击
}
}
rep(i,1,6667) if(dp[i]>=L) ans=min(ans,i);
println(ans);
}
return 0;
}

ZOJ - 3623 完全背包变种的更多相关文章

  1. ZOJ 3623 Battle Ships DP

    B - Battle Ships Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu Subm ...

  2. Course Selection System ZOJ - 3956 01背包+思维

    Course Selection System ZOJ - 3956 这个题目居然是一个01背包,我觉得好难想啊,根本就没有想到. 这个题目把题目给的转化为  ans = a*a-a*b-b*b 这个 ...

  3. HDU 2069 Coin Change(完全背包变种)

    题意:给你5种银币,50 25 10 5 1,问你可以拼成x的所有可能情况个数,注意总个数不超过100个 组合数问题,一看就是完全背包问题,关键就是总数不超过100个.所有我们开二维dp[k][j], ...

  4. [ZOJ 3623] Battle Ships

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

  5. ZOJ 3623 Battle Ships 简单DP

    链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3623 题意:给出N种可以建造的船和对方的塔生命值L,每种船给出建造时 ...

  6. HDU 3466(01背包变种

    http://acm.hdu.edu.cn/showproblem.php?pid=3466 http://www.cnblogs.com/andre0506/archive/2012/09/20/2 ...

  7. poj 1837 天平问题(01背包变种)

    题意:给你n个挂钩,m个砝码,要求砝码都用上,问有多少中方案数 题解:对于这道题目的状态,我们定义一个变量j为平衡度,当j=0的时候,表明天平平衡.定义dp[i][j]表达的含义为使用前n个砝码的时候 ...

  8. 01背包变种 第k解问题 hdu 2639

    先说说普通01包的状态问题吧 普通的01背包,在状态转移的过程中为了求出最优解,一定是遍历了所有的情况 然后再求的最优解.那么对于第k最优解问题,我们只需要再加一个维度,用来记录每一个状态k优解的状态 ...

  9. tyvj1013 - 找啊找啊找GF ——二维背包变种

    题目链接:https://www.tyvj.cn/Problem_Show.aspx?id=1013 好吧,这题没节操=_= 状态f[u,v,i]表示:消费u的人民币和v的人品同时泡到i个mm所需要的 ...

随机推荐

  1. convertTo

    转自 http://blog.csdn.net/xiaxiazls/article/details/51204265 在使用Opencv中,常常会出现读取一个图片内容后要把图片内容的像素信息转为浮点并 ...

  2. 多重if else和switch case的区别

    int main(void) { int id; scanf_s("%d",&id); switch(id) { case 2: printf("John\n&q ...

  3. Luogu 4784 [BalticOI 2016 Day2]城市

    斯坦纳树复习,我暑假的时候好像写过[JLOI2015]管道连接来着. 设$f_{i, s}$表示以$i$为根,$k$个重要点的连通状态为$s$,($0$代表没有连进最小生成树里面去,$1$代表连进了最 ...

  4. Maven——依赖

    一.依赖的范围 依赖的范围有几个可选值,我们用得到的是:compile.test.provided 三个. [1]从项目结构角度理解 compile 和 test 的区别 [2]从开发和运行这两个不同 ...

  5. redis过期key的清理策略

    一,有三种不同的删除策略(1),立即清理.在设置键的过期时间时,创建一个回调事件,当过期时间达到时,由时间处理器自动执行键的删除操作. (2),惰性清理.键过期了就过期了,不管.当读/写一个已经过期的 ...

  6. css总结1:position定位:absolute/relative/fixed

    1 [Positioning(定位)] Positioning作用:指定了元素的定位类型.position包括四个值:static,relative,fixed,absolute. css定位解析:元 ...

  7. Android Hander、Looper、Message三者之间的联系

    1.首先Looper.prepare()在本线程中保存一个Looper实例,然后该实例中保存一个MessageQueue对象:因为Looper.prepare()在一个线程中只能调用一次,所以Mess ...

  8. element时间选择器插件转化为YYYY-MM-DD的形式

    let datete = new Date(this.form.value0);this.form.value0 =datete.getFullYear() +"-" +(date ...

  9. C#分布式存储演练(提供项目下载)

    C#简单的演练了一下分布式的存储,学习fastdns的结构,Client向ProcessCenter请求Storage的服务,然后上传文件. 分布式服务就是多个服务器作为客户端互相[配合],要中心化就 ...

  10. 【SQL】- 基础知识梳理(五) - 触发器

    触发器的概念 触发器对表进行插入.更新.删除的时候会自动执行的特殊存储过程 触发器的语法 create trigger tgr_name on table_name with encrypion –加 ...