博客
关于我
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/

你可能感兴趣的文章
MySQL8修改密码的方法
查看>>
Mysql8在Centos上安装后忘记root密码如何重新设置
查看>>
Mysql8在Windows上离线安装时忘记root密码
查看>>
MySQL8找不到my.ini配置文件以及报sql_mode=only_full_group_by解决方案
查看>>
mysql8的安装与卸载
查看>>
MySQL8,体验不一样的安装方式!
查看>>
MySQL: Host '127.0.0.1' is not allowed to connect to this MySQL server
查看>>
Mysql: 对换(替换)两条记录的同一个字段值
查看>>
mysql:Can‘t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock‘解决方法
查看>>
MYSQL:基础——3N范式的表结构设计
查看>>
MYSQL:基础——触发器
查看>>
Mysql:连接报错“closing inbound before receiving peer‘s close_notify”
查看>>
mysqlbinlog报错unknown variable ‘default-character-set=utf8mb4‘
查看>>
mysqldump 参数--lock-tables浅析
查看>>
mysqldump 导出中文乱码
查看>>
mysqldump 导出数据库中每张表的前n条
查看>>
mysqldump: Got error: 1044: Access denied for user ‘xx’@’xx’ to database ‘xx’ when using LOCK TABLES
查看>>
Mysqldump参数大全(参数来源于mysql5.5.19源码)
查看>>
mysqldump备份时忽略某些表
查看>>
mysqldump实现数据备份及灾难恢复
查看>>