博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
51nod 1614 刷题计划
阅读量:329 次
发布时间: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/

你可能感兴趣的文章