HDU 5188 zhx and contest(带限制条件的 01背包)

Unity+Hybridclr发布WebGL记录 问题不多,比预想中的顺利,如果遇到问题建议先看Hybridclr的常见问题里面有没有解决方案,没遇到Hybridclr的报错,所以记录的问题里面没有Hybridclr相关的。导出设置里的压缩格式选择了Brotli,而服务器或浏览器不支持,据说是可以拓展服务器配置使支持Brotli,但是由于我本人是IIS小白,所以换了种压缩格式,在publishing Settings修改Compression Fromat为Gzip。3.在浏览器运行之后视图一直闪烁。,修改配置,这个网上很常见。 阅读详情

Problem Description
As one of the most powerful brushes in the world, zhx usually takes part in all kinds of contests.
One day, zhx takes part in an contest. He found the contest very easy for him.
There are n problems in the contest. He knows that he can solve the ith problem in ti units of time and he can get vi points.
As he is too powerful, the administrator is watching him. If he finishes the ith problem before time li, he will be considered to cheat.
zhx doesn't really want to solve all these boring problems. He only wants to get no less than w points. You are supposed to tell him the minimal time he needs to spend while not being considered to cheat, or he is not able to get enough points.
Note that zhx can solve only one problem at the same time. And if he starts, he would keep working on it until it is solved. And then he submits his code in no time.
 

Input
Multiply test cases(less than 50). Seek EOF as the end of the file.
For each test, there are two integers n and w separated by a space. (1≤n≤30, 0≤w≤109)
Then come n lines which contain three integers ti,vi,li. (1≤ti,li≤105,1≤vi≤109)
 

Output
For each test case, output a single line indicating the answer. If zhx is able to get enough points, output the minimal time it takes. Otherwise, output a single line saying "zhx is naive!" (Do not output quotation marks).
 

Sample Input
1 3 1 4 7 3 6 4 1 8 6 8 10 1 5 2 2 7 10 4 1 10 2 3
 

Sample Output
7 8 zhx is naive!
 

题意:


  1. 有n道题i题用时ti秒,得分vi,在li时间点之前不能做出来,而且一道题不能分开几次做(一旦开始做,必须在ti时间内把它做完) 
  2.           问得到w分的最小用时是多少 


思路: 把题目按开始做的先后顺序排序,然后o1背包





#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>


#define L(x) (x<<1)
#define R(x) (x<<1|1)
#define MID(x,y) ((x+y)>>1)

#define eps 1e-8
typedef __int64 ll;

#define fre(i,a,b)  for(i = a; i <b; i++)
#define free(i,b,a) for(i = b; i >= a;i--)
#define mem(t, v)   memset ((t) , v, sizeof(t))
#define ssf(n)      scanf("%s", n)
#define sf(n)       scanf("%d", &n)
#define sff(a,b)    scanf("%d %d", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define pf          printf
#define bug         pf("Hi\n")

using namespace std;

#define INF 0x3f3f3f3f
#define N 100005

int dp[30*N];

struct stud{
 int t,l,va;
 bool operator < (const stud a) const
 {
 	   return l-t<a.l-a.t;
 }

}f[40];

int all,sum;
int n,m;

void solve()
{
	int i,j;

	sort(f,f+n);

	int te;

	mem(dp,0);

	fre(i,0,n)
	  free(te,all,f[i].l)
	    if(te>=f[i].t)
	     dp[te]=max(dp[te],dp[te-f[i].t]+f[i].va);

	fre(i,0,all)
	  if(dp[i]>=m) break;

	pf("%d\n",i);
}

int main()
{
	int i,j;
	while(~sff(n,m))
	{
		sum=all=0;
		int temp=0;

		fre(i,0,n)
		 {
		 	sfff(f[i].t,f[i].va,f[i].l);
		    all+=f[i].t;
		    temp=max(temp,f[i].l);
		    sum+=f[i].va;
		 }

	     if(sum<m)
		 {
		 	pf("zhx is naive!\n");
		 	continue;
		 }

		 all=max(all,temp);
		 solve();
	}
     return 0;
}








GD32F4xx MCU ADC+DMA 多通道采样 1、GD32F4xx ADC GD32F4xx 的12位ADC是一种采用逐次逼近方式的模拟数字转换器。 1.1 主要特征 可配置12位、10位、8位、6位分辨率; ADC采样率:12位分辨率为2.6MSPs,10位分辨率为3.0 MSPs。分辨率越低,转换越快; PS: MSPs (模拟混合信号转换速率),是指完成1次从模拟转换到数字的AD转换所需的时间的倒数。常用单位是ksps和Msps,表示每秒采样(千)/(百万)次(kilo / Million Samples per Second)。 1msps 阅读详情

相关推荐

Django 小实例S1 简易学生选课管理系统 —— 〇、初步介绍与演示

python Django实现的一个简易的教务选课系统。 介绍与演示的视频版本已发到我的b站: https://www.bilibili.com/video/BV1er4y1w7ty。 项目已上传到我的github: https://github.com/BigShuang/SimpleStudentCourseManagementSystem。 S1总目录: 〇、初步介绍与演示 一、项目流程梳理与数据库设计 ======================= 大爽歌作,made by big shuang.

大爽老师的博客 5944

hdu 5188

hdu 5188

OJBFOWE的博客 311

高分7(GF7)卫星数据制作平原地区DSM/DEM(三)——可信度分割

李国春(接上)

副组长的博客 1714

hdu5188(带限制条件的01背包)

链接:点击打开链接 题意:有n道题,给出每道题的用时和得分,并且要求在li时间之前不能做出来第i道题,而且一道题不能分开几次做,问至少得到w分需要最少用多长时间 代码: #include #include #include #include #include using namespace std; struct node{ int t,v,l; f

stay_accept的专栏 1926

在overleaf中使用bibtex引用参考文献

最近在挑选写tex的平台,挑来挑去,个人感觉overleaf给我带来的体验感是最舒适的。不过由于对内部的文件组织和make进行了一层封装,所以与一般的本地平台编译tex会有一点不同。此处写一下在overleaf中使用bibtex的方法。 在tex中使用bibtex引用文献是一件很舒适的事,毕竟这是tex的优点之一(要是tex比word难用,我干什么不去用word,hhh) 第一步,我们创建一个.bib文件,名字随便起,我这边起为reference.bib。 然后打开谷歌学术,搜索你想要引用的文章,并找到

锦恢的博客 4万+

Dify部署后访问报502?手把手教你排查和修复Nginx反向代理问题

本文针对Dify部署后常见的502 Bad Gateway错误,提供了从基础容器状态检查到Nginx配置与Docker网络诊断的完整排查流程。详细解析了错误本质,并给出动态服务发现修复与静态IP配置两种解决方案,帮助开发者彻底解决Nginx反向代理问题,确保Dify平台稳定访问。

rnn9storyteller的博客 1096

hdu 5188(限制01背包)

zhx and contest Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Problem Description As one of the most powerful brushes in the world, zhx usually takes p

hexianhao的博客 384

FreeRtos——10、全局看门狗设计

RTOS 里的看门狗不只是为了证明 CPU 还在动,而是为了证明每个业务逻辑都在按预期的节奏“呼吸”。

qq_40170041的博客 900

hdu5188 加限制的01背包问题

http://acm.hdu.edu.cn/showproblem.php?pid=5188 Problem Description As one of the most powerful brushes in the world, zhx usually takes part in all kinds of contests. One day, zhx take...

weixin_34008784的博客 137

PMP--二模--解题--161-170

A:邀请团队成员在下一次回顾中分享经验。B:请求发起人增加具有所需经验的团队成员。C:在团队内计划知识共享会议。D:请求发起人为团队提供培训课程。A。

stqer的博客 1268

PDAF相位对焦原理

pdaf光路图

camerall 1万+

HDU 5188 zhx and contest(有限制01背包)

题意就是给你一些事要做,有的事至少要在>=l的时间完成才行。 做法讲起来很简单,按照l-t的大小进行排序,然后普通的01背包。 为何?首先这题01背包是指做了先前的事再做当前这件事来递推最优。想一下,如果2件事的l-t(即最小可以开始做的时间)都在比较前面,那么我这两件事紧接着做,从第i时间开始,那么交换顺序也没有关系,反正都是在i+t1+t2完成,得到的价值也是v1+v2,但是什么情况下会出

glq007的acm的奋斗 785

2023.03.27更新大麦网PC端抢购软件和使用教程

近期发现大麦网页端抢购页面悄然发生变化,之前可以在页面选择票价、档次,并且点击按钮进行购票,现在不行了,新的页面如下图所示。已经安全没有了点击按钮,因此,但是并不代表不能像以前之前那样。

猫敷雪 1万+

HDU 5188 · zhx and contest【01背包】【约束条件】

dp,01背包问题,难度中等。

张天枭の博客 560

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

HDU 5188 zhx and contest 01背包的变形

题目描述:Problem Description As one of the most powerful brushes in the world, zhx usually takes part in all kinds of contests. One day, zhx takes part in an contest. He found the contest very easy for h

喵头鹰的博客 473

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

hdu 5188 zhx and contest(有限制的01背包问题)

zhx and contest Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 755    Accepted Submission(s): 281 Problem Description As one of th

TUT我好菜啊 632

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

HDU-5188-zhx and contest【01背包】

题目大意:给出n道题目,每道题目给出t,v,l。每道题目需要t时间去完成,必须在l及l时间之后完成。v是完成这道题目获得的分值。问,需要获得大于等于w分,最快什么时候能完成。

Linoy 544

【01背包+限制条件】HDU5188-zhx and contest【BestCoder Round #33】

题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=5188 Problem Description As one of the most powerful brushes in the world, zhx usually takes part in all kinds of contests. One day, zhx t

wlxsq的专栏 381

HDU5188:zhx and contest(类01背包)

zhx and contest Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 828    Accepted Submission(s): 316 Problem Description As one of th

junior19的博客 357

HUD 5188(zhx and contest)有条件01背包

这题看到背包有个前提条件的,很快可以想到HDU3466 Proud Merchants,也是有前提条件的 li-ti是最早开始的时间,我们尽量从时间早的开始选,即li-ti从小到大排序。 还有这种要满足某某要求时所需某某最少的,基本都是先算每个状态所能达到的最大值,然后从前往后扫描第一次达到所求值时,这个状态就是所要求的最小。 代码: #include #include #include

小铅笔 534

hdu5188限制01背包

zhx and contest Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 731    Accepted Submission(s): 271 Problem Description As one of th

猿的进化 512

HDU5188(有限制的01背包)

zhx and contest Problem Description As one of the most powerful brushes in the world, zhx usually takes part in all kinds of contests. One day, zhx takes part in an contest. He found the contest ver

MrBlank的ACM记事本 407

hdu 5188 (zhx and contest)

题意:zhx在比赛的时候有n道题目,第i道题目有一个分值vi,需要ti时间做完,而且必须在li或li之后完成。问zhx在获得至少w分数的情况下需要的最少时间。 做法:类似于01背包的做法,第i题可以选择做或者不做。先对题目按照li-ti(即第i道题最早的开始时间)从小到大进行排序。然后遍历,在此过程中维护一个top值,top指的是完成前I题之后尽可能迟的时间值。对于第i道题,li-ti到top的

84970000的专栏 765

HDU 5188 背包

有N道题,要求得到最少W分 给出N道题的:每道题用时T,分数V,应在且必须在L时刻提交才能得分 问得到W分所用的最少的时间 以L-T排序,然后做01背包即可 #include "stdio.h" #include "algorithm" #include "string.h" using namespace std; struct Mark { int t,v,l

845

hdu5188 二分 or 背包

题目关键在于,对于时间最少的方法的方法,一定按照题目最早可以开始做的时间的顺序做,即按照l-t的从小到大顺序来做。 不妨假设1的开始时间小于2,那么一旦先做2,很明显从做完上件题目后的等待时间加长,因此可以得出最优解一定按照l-t的顺序做。 然后就是两种方法了,一种背包,一种二分,背包是求出了每个时间的最优值,而二分加dfs只是不断验证是否可行再二分的过程,事实证明,后者省去很多时间。 附代

creater_X 653
上一篇: 九度 OJ 1554:区间问题 (set +前缀 +map)
下一篇: POJ 2151 Check the difficulty of problems(概率dp)
左眼皮跳跳~
博客等级 码龄13年 17粉丝 400原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值