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

  1. type
  2. arr=record
  3. toward,next,cap,cost:longint;
  4. end;
  5. const
  6. maxm=;
  7. maxn=;
  8. mm=<<;
  9. var
  10. edge:array[..maxm]of arr;
  11. first,slack,d:array[..maxn]of longint;
  12. chose:array[..maxn]of boolean;
  13. n,maxflow,maxcost,s,t,tot,esum:longint;
  14.  
  15. function min(x,y:longint):longint;
  16. begin
  17. if x<y then exit(x);
  18. exit(y);
  19. end;
  20.  
  21. procedure add(i,j,k,l:longint);
  22. begin
  23. inc(esum);
  24. edge[esum].toward:=j;
  25. edge[esum].next:=first[i];
  26. first[i]:=esum;
  27. edge[esum].cap:=k;
  28. edge[esum].cost:=l;
  29. end;
  30.  
  31. procedure addedge(i,j,k,l:longint);
  32. begin
  33. add(i,j,k,l);
  34. add(j,i,,-l);
  35. end;
  36.  
  37. function aug(x,flow:longint):longint;
  38. var
  39. now,more,i,too,value:longint;
  40. begin
  41. if x=t then begin
  42. inc(maxflow,flow);
  43. inc(maxcost,flow*d[s]);
  44. exit(flow);
  45. end;
  46. chose[x]:=true;
  47. i:=first[x];
  48. now:=;
  49. while i>= do begin
  50. too:=edge[i].toward;
  51. value:=edge[i].cost;
  52. if (edge[i].cap>) and (not chose[too]) then
  53. if d[x]=d[too]+value then begin
  54. more:=aug(too,min(flow-now,edge[i].cap));
  55. dec(edge[i].cap,more);
  56. inc(edge[i xor ].cap,more);
  57. inc(now,more);
  58. if flow=now then exit(flow);
  59. end
  60. else
  61. slack[too]:=min(slack[too],d[too]+value-d[x]);
  62. i:=edge[i].next;
  63. end;
  64. exit(now);
  65. end;
  66.  
  67. function rel:boolean;
  68. var
  69. i,spent:longint;
  70. begin
  71. spent:=maxlongint;
  72. for i:= to tot do
  73. if not chose[i] then spent:=min(spent,slack[i]);
  74. if spent>=mm then exit(false);
  75. for i:= to tot do
  76. if chose[i] then inc(d[i],spent);
  77. exit(true);
  78. end;
  79.  
  80. procedure into;
  81. var
  82. i,j,k,m,sum:longint;
  83. begin
  84. esum:=-;
  85. fillchar(first,sizeof(first),);
  86. readln(n,m,sum);
  87. tot:=n+;
  88. s:=tot-;
  89. t:=tot;
  90. for i:= to n do begin
  91. read(j);
  92. addedge(i,t,j,);
  93. end;
  94. for i:= to n do begin
  95. read(j);
  96. addedge(s,i,maxlongint,j);
  97. end;
  98. for i:= to n- do
  99. addedge(i,i+,sum,m);
  100. end;
  101.  
  102. begin
  103. into;
  104. fillchar(d,sizeof(d),);
  105. maxflow:=;
  106. maxcost:=;
  107. repeat
  108. fillchar(slack,sizeof(slack),$7f);
  109. repeat
  110. fillchar(chose,sizeof(chose),false);
  111. until aug(s,maxlongint)<=;
  112. until not rel;
  113. writeln(maxcost);
  114. readln;
  115. readln;
  116. 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. Ruby 基础教程1-6

    1.循环实现方法 循环语句 (while;for; loop,until) 循环方法(times,each) 2.for           for 变量 in 对象             主体   ...

  2. 如何用istio实现应用的灰度发布

    Istio为用户提供基于微服务的流量治理能力.Istio允许用户按照标准制定一套流量分发规则,并且无侵入的下发到实例中,平滑稳定的实现灰度发布功能. 基于华为云的Istio服务网格技术,使得灰度发布全 ...

  3. 第一篇 HTML基础

    浏览网页,就是上网,上网的本质就是下载内容. 浏览器是个解释器,用来执行HTML.css.JS代码的. HTML,CSS, JavaScript 号称网络三剑客. 1. 浏览器发送一个域名给服务端 2 ...

  4. ortp代码简析

    ortp初始化 /** *    Initialize the oRTP library. You should call this function first before using *     ...

  5. Samba共享权限分配

    案例推荐:http://www.cnblogs.com/mchina/archive/2012/12/18/2816717.html 本文不详细介绍全部参数,只介绍完成需求的一些参数. 需求: 1,账 ...

  6. 为什么23种设计模式中没有MVC

    GoF (Gang of Four,四人组, <Design Patterns: Elements of Reusable Object-Oriented Software>/<设计 ...

  7. Notes of the scrum meeting before publishing2(12.18)

    meeting time:18:30~20:30p.m.,December 18th,2013 meeting place:3号公寓一层 attendees: 顾育豪                  ...

  8. Notes of the scrum meeting(12.9)

    meeting time:14:00~17:00p.m.,December 9th,2013 meeting place:一号教学楼209 attendees: 顾育豪                 ...

  9. A4

    队名:起床一起肝活队 组长博客:博客链接 作业博客:班级博客本次作业的链接 组员情况 组员1(队长):白晨曦 过去两天完成了哪些任务 描述: 很胖,刚学,照猫画虎做了登录与注册界面. 展示GitHub ...

  10. Median of Two Sorted Arrays(hard)

    题目要求: 有两个排序的数组nums1和nums2分别为m和n大小. 找到两个排序数组的中位数.整体运行时间复杂度应为O(log(m + n)). 示例: 我的方法: 分别逐个读取两个数组的数,放到一 ...