博客
关于我
51nod 1614 刷题计划
阅读量:333 次
发布时间:2019-03-03

本文共 1338 字,大约阅读时间需要 4 分钟。

题意

大赛将至,摆在你面前的是n道题目,第 i(1 ≤ i ≤ n) 道题目能提升 ai 点智力值,代码量为 bi KB,无聊值为 ci ,求至少提升m点智力值的情况下,所做题目代码量之和*无聊值之和最小为多少。

题解

像最小乘积树那么做就可以了

就是吧一个k**(我不会拼)的过程改成DP而已
别的就直接上模板就可以了

感觉这种求乘积的都可以这么做啊

很套路的感觉啊

#include
#include
#include
#include
using namespace std;typedef long long LL;const LL MAX=1LL<<55;const LL N=405;LL n,m;LL a[N],b[N],c[N];LL d[N];struct node{LL x,y;}s[N];LL ans=MAX;LL f[N][1005];//前i个,达到标准的最小值 bool g[N][1005];node DP (){ for (LL u=0;u<=n;u++) for (LL i=0;i<=800;i++) f[u][i]=MAX; f[0][0]=0; for (LL u=0;u
=1;u--) if (g[u][k]) { k=k-a[u]; p.x+=b[u]; p.y+=c[u]; }// printf("YES:%lld %lld\n",p.x,p.y); ans=min(ans,p.x*p.y); return p;}LL mul (node x,node y,node z){ LL x1=x.x-z.x,y1=x.y-z.y; LL x2=y.x-z.x,y2=y.y-z.y; return x1*y2-x2*y1;}void solve (node x,node y){ LL yy=x.y-y.y,xx=y.x-x.x; for (LL u=1;u<=n;u++) d[u]=b[u]*yy+c[u]*xx; node p=DP(); if (mul(p,x,y)>=0) return ; solve(x,p);solve(p,y);}int main(){ scanf("%lld%lld",&n,&m); for (LL u=1;u<=n;u++) scanf("%lld%lld%lld",&a[u],&b[u],&c[u]); for (LL u=1;u<=n;u++) d[u]=b[u]; node a=DP(); for (LL u=1;u<=n;u++) d[u]=c[u]; node b=DP(); solve(a,b); printf("%lld\n",ans); return 0;}

转载地址:http://wacq.baihongyu.com/

你可能感兴趣的文章
MySQL5.7.37windows解压版的安装使用
查看>>
mysql5.7免费下载地址
查看>>
mysql5.7命令总结
查看>>
mysql5.7安装
查看>>
mysql5.7性能调优my.ini
查看>>
MySQL5.7新增Performance Schema表
查看>>
Mysql5.7深入学习 1.MySQL 5.7 中的新增功能
查看>>
Webpack 之 basic chunk graph
查看>>
Mysql5.7版本单机版my.cnf配置文件
查看>>
mysql5.7的安装和Navicat的安装
查看>>
mysql5.7示例数据库_Linux MySQL5.7多实例数据库配置
查看>>
Mysql8 数据库安装及主从配置 | Spring Cloud 2
查看>>
mysql8 配置文件配置group 问题 sql语句group不能使用报错解决 mysql8.X版本的my.cnf配置文件 my.cnf文件 能够使用的my.cnf配置文件
查看>>
MySQL8.0.29启动报错Different lower_case_table_names settings for server (‘0‘) and data dictionary (‘1‘)
查看>>
MYSQL8.0以上忘记root密码
查看>>
Mysql8.0以上重置初始密码的方法
查看>>
mysql8.0新特性-自增变量的持久化
查看>>
Mysql8.0注意url变更写法
查看>>
Mysql8.0的特性
查看>>
MySQL8修改密码报错ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
查看>>