直接费用流,天数就是点数

type
arr=record
toward,next,cap,cost:longint;
end;
const
maxm=;
maxn=;
mm=<<;
var
edge:array[..maxm]of arr;
first,slack,d:array[..maxn]of longint;
chose:array[..maxn]of boolean;
n,maxflow,maxcost,s,t,tot,esum:longint; function min(x,y:longint):longint;
begin
if x<y then exit(x);
exit(y);
end; procedure add(i,j,k,l:longint);
begin
inc(esum);
edge[esum].toward:=j;
edge[esum].next:=first[i];
first[i]:=esum;
edge[esum].cap:=k;
edge[esum].cost:=l;
end; procedure addedge(i,j,k,l:longint);
begin
add(i,j,k,l);
add(j,i,,-l);
end; function aug(x,flow:longint):longint;
var
now,more,i,too,value:longint;
begin
if x=t then begin
inc(maxflow,flow);
inc(maxcost,flow*d[s]);
exit(flow);
end;
chose[x]:=true;
i:=first[x];
now:=;
while i>= do begin
too:=edge[i].toward;
value:=edge[i].cost;
if (edge[i].cap>) and (not chose[too]) then
if d[x]=d[too]+value then begin
more:=aug(too,min(flow-now,edge[i].cap));
dec(edge[i].cap,more);
inc(edge[i xor ].cap,more);
inc(now,more);
if flow=now then exit(flow);
end
else
slack[too]:=min(slack[too],d[too]+value-d[x]);
i:=edge[i].next;
end;
exit(now);
end; function rel:boolean;
var
i,spent:longint;
begin
spent:=maxlongint;
for i:= to tot do
if not chose[i] then spent:=min(spent,slack[i]);
if spent>=mm then exit(false);
for i:= to tot do
if chose[i] then inc(d[i],spent);
exit(true);
end; procedure into;
var
i,j,k,m,sum:longint;
begin
esum:=-;
fillchar(first,sizeof(first),);
readln(n,m,sum);
tot:=n+;
s:=tot-;
t:=tot;
for i:= to n do begin
read(j);
addedge(i,t,j,);
end;
for i:= to n do begin
read(j);
addedge(s,i,maxlongint,j);
end;
for i:= to n- do
addedge(i,i+,sum,m);
end; begin
into;
fillchar(d,sizeof(d),);
maxflow:=;
maxcost:=;
repeat
fillchar(slack,sizeof(slack),$7f);
repeat
fillchar(chose,sizeof(chose),false);
until aug(s,maxlongint)<=;
until not rel;
writeln(maxcost);
readln;
readln;
end.

bzoj 2424: [HAOI2010]订货 (费用流)的更多相关文章

  1. BZOJ 2424: [HAOI2010]订货 费用流

    2424: [HAOI2010]订货 Description 某公司估计市场在第i个月对某产品的需求量为Ui,已知在第i月该产品的订货单价为di,上个月月底未销完的单位产品要付存贮费用m,假定第一月月 ...

  2. BZOJ 2424: [HAOI2010]订货(最小费用最大流)

    最小费用最大流..乱搞即可 ------------------------------------------------------------------------------ #includ ...

  3. BZOJ 2424: [HAOI2010]订货

    2424: [HAOI2010]订货 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 915  Solved: 639[Submit][Status][ ...

  4. BZOJ 2424: [HAOI2010]订货(费用流)

    裸的费用流了= =从源点向每个点连费用为di,从汇点向每个点连流量为ui,每个点向下一个点连费用为m,流量为s的边就行了 CODE: #include<cstdio>#include< ...

  5. 【bzoj2424】[HAOI2010]订货 费用流

    原文地址:http://www.cnblogs.com/GXZlegend/p/6825296.html 题目描述 某公司估计市场在第i个月对某产品的需求量为Ui,已知在第i月该产品的订货单价为di, ...

  6. BZOJ2424 [HAOI2010]订货 - 费用流

    题解 (非常裸的费用流 题意有一点表明不清: 该月卖出的商品可以不用算进仓库里面. 然后套上费用流模板 代码 #include<cstring> #include<queue> ...

  7. BZOJ 2424 DP OR 费用流

    思路: 1.DP f[i][j]表示第i个月的月底 还剩j的容量 转移还是相对比较好想的-- f[i][j+1]=min(f[i][j+1],f[i][j]+d[i]); if(j>=u[i+1 ...

  8. 2424: [HAOI2010]订货

    2424: [HAOI2010]订货 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 922  Solved: 642[Submit][Status][ ...

  9. [bzoj 1449] 球队收益(费用流)

    [bzoj 1449] 球队收益(费用流) Description Input Output 一个整数表示联盟里所有球队收益之和的最小值. Sample Input 3 3 1 0 2 1 1 1 1 ...

随机推荐

  1. [JSON].remove( keyPath )

    语法:[JSON].remove( keyPath ) 返回:无 说明:移除指定路径的键 示例: Set jsonObj = toJson("{div:{'#text-1': 'is tex ...

  2. Memcached命令-存储命令-查找命令-清理命令

    Memcached set 存储命令 Memcached set 命令用于将 value(数据值) 存储在指定的 key(键) 中. 如果set的key已经存在,该命令可以更新该key所对应的原来的数 ...

  3. JAVA基础学习之路(三)类定义及构造方法

    类的定义及使用 一,类的定义 class Book {//定义一个类 int price;//定义一个属性 int num; public static int getMonney(int price ...

  4. DP动态规划练习

    先来看一下经典的背包问题吧 http://www.cnblogs.com/Kalix/p/7617856.html  01背包问题 https://www.cnblogs.com/Kalix/p/76 ...

  5. mapReduce入门教程

    什么是MapReduce MapReduce是Google提出的一个软件架构,用于大规模数据集(大于1TB)的并行运算.概念"Map(映射)"和"Reduce(归纳)&q ...

  6. javaee Listener

    Servlet API 中定义了几种监听器,大多数尽管不是全部,都将监听某种形式的会话活动,通过实现对应事件的监听器接口订阅某个事件,然后在部署描述符中添加 <listener> 配置,或 ...

  7. Machine Learning笔记整理 ------ (三)基本性能度量

    1. 均方误差,错误率,精度 给定样例集 (Example set): D = {(x1, y1), (x2, y2), (x3, y3), ......, (xm, ym)} 其中xi是对应属性的值 ...

  8. Trie 树——搜索关键词提示

    当你在搜索引擎中输入想要搜索的一部分内容时,搜索引擎就会自动弹出下拉框,里面是各种关键词提示,这个功能是怎么实现的呢?其实底层最基本的就是 Trie 树这种数据结构. 1. 什么是 "Tri ...

  9. Python中的slice操作

    Python中slice操作的完整语法: # i默认是0 # j默认是len(S) # k的步长,默认为+1 S[i:j:k] 其中i,j,k都可以是负数: 若i < 0或者k<0,等价于 ...

  10. 20145214《Java程序设计》课程总结

    20145214<Java程序设计>课程总结 每周读书笔记链接汇总 第一周读书笔记 第二周读书笔记 第三周读书笔记 第四周读书笔记 第五周读书笔记 第六周读书笔记 第七周读书笔记 第八周读 ...