题意理解有误导致方程建歪,题意是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;
}

最新文章

  1. PHP 的 __FILE__ 常量
  2. 支持向量机(SVM)——python3实现
  3. xshell传输文件到Centos
  4. (视频) 《快速创建网站》 2.3 WordPress初始化和功能简介
  5. Android中dip、dp、sp、pt和px的区别
  6. ubuntu 12.04 &quot;系统的网络服务与此版本的网络管理器不兼容
  7. MySQLdb模块操作
  8. dpkg的用法
  9. 3036: 绿豆蛙的归宿 - BZOJ
  10. 应用XML作为数据库的快速开发框架
  11. C# FileStream复制大文件
  12. EF框架搭建
  13. Deploy a Sharded Cluster
  14. SendMessage基本认识
  15. 带有机器人框架的.NET自己主动化測试
  16. HDU 4819 Mosaic D区段树
  17. python-桶排序
  18. 编译原理:基于状态转换图识别for语句
  19. ELK日志分析平台搭建
  20. RxJava2学习笔记(2)

热门文章

  1. Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.38/images/json: dial unix /var/run/docker.sock: conne
  2. SHELL读取 ini 格式文件做配置文件
  3. Makefile 编写规则 - 1
  4. Smarty3&mdash;&mdash;foreach
  5. linux蓝屏时间修改
  6. Part10-C语言环境初始化-Bss段初始化lesson2
  7. IIS关闭Trace、OPTIONS方法
  8. 使用 Vue.component
  9. reportng定制修改
  10. LIS问题---HDU1025 Constructing Roads In JGShining&#39;s Kingdom