ZOJ 3956 Course Selection System

[QMT量化交易小白入门]-七十一、十年回测ETF动量策略,超额年化收益率为10.6% 本专栏主要是介绍QMT的基础用法,常见函数,写策略的方法,也会分享一些量化交易的思路,大概会写100篇左右。QMT的相关资料较少,在使用过程中不断的摸索,遇到了一些问题,记录下来和大家一起沟通,共同进步。 阅读详情

01背包

如果你能发现C不变,H越大,公式值越大,这题就可以用01背包写了

C代表容量~dp[i]代表到使用前i种所能达到最大的H值

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <algorithm>  
#include <iostream>  
#include <cstdlib>  
#include <cstring>  
#include <string>
#include <cstdio>  
#include <climits>
#include <cmath> 
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <sstream>
#define INF 0x3f3f3f3f
#define LL long long
#define fora(i,a,n) for(int i=a;i<=n;i++)
#define fors(i,n,a) for(int i=n;i>=a;i--)
#define sci(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define MAXN 100024
const double eps = 1e-8;
using namespace std;
LL dp[50024];
LL h[524], c[524];
int t, n;
int main() {
#ifdef DID
	freopen("in.txt", "r", stdin);
	//freopen("out.txt","w",stdout);
#endif
	sci(t);
	while (t--) {
		sci(n);
		LL Min=0;
		fora(i, 1, n) {
			sci(h[i]), sci(c[i]);
			Min += c[i];
		}
		fora(i, 0, Min) dp[i] = -INF;
		dp[0] = 0;
		fora(i, 1, n)
			fors(j, Min,c[i]) {
			dp[j] = max(dp[j], dp[j - c[i]] + h[i]);
		}
		LL Max = -1;
		fora(i, 1, Min) {
			if (dp[i] >= 0)
				Max = max(Max, dp[i] * dp[i] - dp[i] * i - i*i);
		}
		if (Max < 0) printf("0\n");
		else printf("%lld\n", Max);
	}
	return 0;
}


VMware报错系列:虚拟机配置文件(.vmx)损坏或丢失---修复 虚拟机配置文件(.vmx)损坏或丢失---修复 阅读详情

相关推荐

一文看懂分布式存储架构

目录一、集中存储结构二、分布式存储1 、分布式存储的兴起2 、分布式存储的重要性3 、分布式存储的种类和比较三、分布式理论浅析1 、一致性和可用性2 、数据分布3 、复制4 、分布式协议5、跨机房部署四、分布式文件系统1、 Google 文件系统( GFS )2、 Taobao 文件系统( TFS )3、 Fackbook Haystack 文件系统4、 CDN 内容分发网络五、分布式键值系统1、 Amazon Dynamo2、 Taobao Tiar3、 ETCD4 、产品选型比较( Etcd , Zoo

weixin_70730532的博客 2万+

【ZOJ3956】Course Selection System(01背包+思维)

题目链接 Course Selection System Time Limit: 1 Second      Memory Limit: 65536 KB There are n courses in the course selection system of Marjar University. The i-th course is described by two values: ha...

よろしくお願いします 283

一文读懂客户健康度

什么是客户健康度?客户健康度为什么重要?怎么计算客户健康度?这篇文章,我们来聊聊。

m0_62700043的博客 1420

ZOJ 3956 Course Selection System 01背包

Course Selection System Time Limit: 1 Second      Memory Limit: 65536 KB There are n courses in the course selection system of Marjar University. The i-th course is described by two values:

计算机技术 1205

电阻的基本原理、参数、应用与选型

电阻的基本原理、电阻的分类、参数,应用与选型,0欧姆电阻的介绍等。

luobeihai的博客 1万+

【目标跟踪】ECO算法论文阅读:ECO: Efficient Convolution Operators for Tracking

这里所指的训练集是指保存了每一帧的跟踪结果的训练集,也就是说,每一次进行model update的时候,要用在这一帧之前所有跟踪到的样本。那么随着视频越来越长,这个训练集就会越来越大。因为当目标被遮挡或者丢失的时候,比较新的这些样本本身就是错的,那么模型很容易有model drift,就是被背景或者错误的目标污染,导致跟踪结果出错。如下图所示,Baseline是传统的训练集,每更新一帧就加一个进来,那么连续的数帧后训练集里面的样本都是高度相似的,即容易遗忘前面的样本,且容易对最近的若干帧样本过拟合。

qq_43799400的博客 2615

Zoj 3956 Course Selection System (01背包)

Course Selection System Time Limit: 1 Second      Memory Limit: 65536 KB There are n courses in the course selection system of Marjar University. The i-th course is described by two values: ha

K键盘里的青春K 853

贝叶斯时空模型-INLA-4

该文章中,会简化数学计算的过程,主要是针对,在有数据的基础上,如何应用贝叶斯时空模型,找出影响因素,绘制时间变化的空间分布预测图。上述中关键一步与前几期介绍的不一样的地方是,我们加入了n.group参数,用来指定年份,先看一下Year有多少年的,然后封装在s.index里面。在前述的内容中,我们介绍了,如何处理空间的数据,利用海拔高度预测降雨量的例子。建立好数据及mesh以后,我们现在写INLA公式,如果不考虑残差项,那就是固定效应,现在我们增加残差项,及空间与时间效应。这里的Mesh设定值为10,20。

学习中 2948

ZOJ - 3956 Course Selection System——01背包变形

There are n courses in the course selection system of Marjar University. The i-th course is described by two values: happiness Hi and credit Ci. If a student selects m courses x1, x2, ..., xm, the

hao_zong_yin的博客 696

Google Earth Engine——使用STARFM 图像融合算法将Landsat 和 MODIS 融合得出2000-2023 NDVI长时序图(空间分辨率为 30 米、时间分辨率为 16 天)

非本地入侵物种是全球生态系统面临的主要威胁之一。野葛(Pueraria montana)是一种生长迅速的藤本植物,原产于亚洲,现已入侵美国一些地区,因此该物种的管理成为一个重要问题。利用 Landsat 和 MODIS 平台收集的数据,计算了 2000 年至 2015 年肯塔基州三个侵扰地点的归一化差异植被指数(NDVI)估算值。使用 STARFM 图像融合算法将大地遥感卫星和 MODIS 得出的 NDVI 结合成空间分辨率为 30 米、时间分辨率为 16 天的时间序列。

此星光明博客 2509

基于深度学习的野生菌菇检测识别分类系统(YOLOv8 + UI界面 + 数据集)

随着深度学习技术的迅猛发展,计算机视觉领域的应用得到了广泛的关注。野生菌菇的检测与识别是一个复杂而又有趣的问题,涉及到物体检测、图像分类以及自然语言处理等技术。本文将介绍如何基于YOLOv8模型,结合自定义UI界面与数据集,构建一个高效且精确的野生菌菇检测识别分类系统。首先,我们将介绍YOLOv8的原理与特点,然后详细描述如何构建和训练野生菌菇识别模型,并介绍如何为该系统设计UI界面,最终形成一个完整的系统。本文内容包括代码实现、模型训练及数据集准备等,旨在为有类似需求的开发者提供参考和帮助。目录摘要目录。

YOLO 1547

Course Selection System ZOJ - 3956

题意:here are n courses in the course selection system of Marjar University. The i-th course is described by two values: happiness Hi and credit Ci. If a student selects m courses x1, x2, ..., xm, then ...

Ma_tx 387

一步到位解决Docker拉取镜像失败的问题!超详细的Docker代理设置教程!(使用代理解决群晖Docker获取注册表失败的问题)

一步到位解决Docker拉取镜像失败的问题!超详细的Docker代理设置教程!(使用代理解决群晖Docker获取注册表失败的问题)

XiaoqiangClub的博客 1万+

ZOJ3956 Course Selection System

There are n courses in the course selection system of Marjar University. The i-th course is described by two values: happiness Hi and credit Ci. If a student selects m courses x1, x2, …, xm, then his ...

突破吧!次元壁 210

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

zoj3956 Course Selection System (背包)

Course Selection System Time Limit: 1 Second      Memory Limit: 65536 KB There are n courses in the course selection system of Marjar University. The i-th course is described by two values: ha

YitongJun的博客 501

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

Course Selection System(ZOJ-3956)

Problem Description There arencourses in the course selection system of Marjar University. Thei-th course is described by two values: happinessHiand creditCi. If a student selectsmcoursesx1...

Alex_McAvoy的博客 560

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

ZOJ 3956 Course Selection System(01背包)

Course Selection System Time Limit: 1 Second      Memory Limit: 65536 KB There are n courses in the course selection system of Marjar University. The i-th course is described by two values: ha

CillyB的博客 959

ZOJ 3956 Course Selection System 背包DP

ZOJ3956观察数据范围, c的值非常小 只有100 所以c的和也很有限 只有50000 是否可以从这里下手? 对于某一个c的和 我们一定希望h的和最大 才有可能是最终答案。 于是有了类似背包的dp方程。 代码很简单,就不给出方程了。 //比赛的时候想得太多,都想到斜率优化上了,完全忽略了c的范围这么小!!!毕竟图样。 //一个人的面命运,当然要靠自我奋斗,但是也要考虑到历史的行程。 ...

weixin_30569033的博客 102

「ZOJ3956」Course Selection System

「ZOJ3956」Course Selection System这是一道很好的关于01背包的题目。背包中的费用和价值不好去找。

ybC202444的博客 167

ZOJ 3956 Course Selection System (01背包)

Course Selection System Time Limit:1 Second Memory Limit:65536 KB There arencourses in the course selection system of Marjar University. Thei-th course is described by two values: happines...

LSD20164388的博客 439

ZOJ-3956 Course Selection System(01背包)

题意 有 nnn 门课程,每门课程都有它的快乐值 HiHiH_i,学分 CiCiC_i。现在选择若干门课程(可不选),它们的舒适值的结果满足下式: (∑imHxi)2−∑imHxi∑imCxi−(∑imCxi)2(∑imHxi)2−∑imHxi∑imCxi−(∑imCxi)2(\displaystyle\sum_i^mHx_i)^2-\displaystyle\sum_i^mHx_i\disp...

Paulliant的博客 337

ZOJ 3956 Course Selection System 01背包变形

题目链接    题意: 给你n个hi, ci,问你怎样拿才能让你 使上面式子最大。   思路: 根据上面的式子我们可知,对于一个C值当hi越大,则上面的式子才可能更大一些,又因为题目中C的值很小最多 50000,所以我们可以以C为背包容量 c[i]为体积h为价值进行01背包,然后维护一下最大值. 真的是很巧妙的问法,当时有想过dp,想到了背包可是没有明确怎么背,,,哎 orz #i

Marcus-Bao的个人主页 1050

ZOJ 3956 Course Selection System 01背包

Course Selection System Time Limit: 1 Second      Memory Limit: 65536 KB There are n courses in the course selection system of Marjar University. The i-th course is described by two values: ha

jerans的博客 1085

zoj 3956 Course Selection System

Course Selection System Time Limit: 1 Second      Memory Limit: 65536 KB There are n courses in the course selection system of Marjar University. The i-th course is described by two values: happ

三水的鱼塘♂ 323

ZOJ 3956——Course Selection System(01背包)

题目链接: 因为c的值很小,所以以c看做重量,把h当做价值 01背包,取尽可能大的h 因为当c固定时,这个式子只需要看前面 h*h-h*c=h*(h-c) h大于c时,肯定h越大越好 h小于c时,表达式的值必定小于零,肯定是不考虑的 #include &lt;cstdio&gt; #include &lt;cmath&gt; #include&lt;vector&gt; #inclu...

ZMST的博客 242
上一篇: ZOJ 3953 Intervals
下一篇: Fibonacci again and again HDU - 1848
DIDCJS
博客等级 码龄11年 5粉丝 31原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值