bzoj 1221: [HNOI2001] 软件开发 (网络流)
注意说如果直接从每天的新的连向旧的,那整个图的最大流还是不变,答案就一直会是Σni*f
type
arr=record
toward,next,cap,cost:longint;
end;
const
maxm=;
maxn=;
var
edge:array[..maxm]of arr;
dist,first,slack:array[..maxn]of longint;
chose:array[..maxn]of boolean;
n,m,s,t,tot,esum,i,maxflow,maxcost: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,dist[s]*flow);
exit(flow);
end;
now:=;
chose[x]:=true;
i:=first[x];
while i>= do begin
too:=edge[i].toward;
value:=edge[i].cost;
if (edge[i].cap>) and (not chose[too]) then
if dist[x]=dist[too]+value then begin
more:=aug(too,min(edge[i].cap,flow-now));
dec(edge[i].cap,more);
inc(edge[i xor ].cap,more);
inc(now,more);
if now=flow then exit(flow);
end
else
slack[too]:=min(slack[too],dist[too]+value-dist[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=maxlongint then exit(false);
for i:= to tot do
if chose[i] then inc(dist[i],spent);
exit(true);
end; procedure into;
var
n,timea,timeb,cost1,costa,costb,i,j:longint;
begin
readln(n,timea,timeb,cost1,costa,costb);
fillchar(first,sizeof(first),);
esum:=-;
s:=n<<+;
t:=n<<+;
tot:=t;
for i:= to n do begin
read(j);
addedge(s,i,j,cost1);
addedge(s,i+n,j,);
addedge(i,t,j,);
end;
for i:= to n do begin
for j:=i+timea+ to n do
addedge(i+n,j,maxlongint,costa);
for j:=i+timeb+ to n do
addedge(i+n,j,maxlongint,costb);
end;
end; begin
into;
repeat
for i:= to tot do slack[i]:=maxlongint;
repeat
fillchar(chose,sizeof(chose),false);
until aug(s,maxlongint)<=;
until not rel;
writeln(maxcost);
readln;
readln;
end.
bzoj 1221: [HNOI2001] 软件开发 (网络流)的更多相关文章
- BZOJ 3280: 小R的烦恼 & BZOJ 1221: [HNOI2001] 软件开发
3280: 小R的烦恼 Time Limit: 10 Sec Memory Limit: 512 MBSubmit: 399 Solved: 200[Submit][Status][Discuss ...
- BZOJ 1221: [HNOI2001] 软件开发
1221: [HNOI2001] 软件开发 Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 1428 Solved: 791[Submit][Stat ...
- BZOJ 1221: [HNOI2001] 软件开发(最小费用最大流)
不知道为什么这么慢.... 费用流,拆点.... --------------------------------------------------------------------------- ...
- bzoj 1221 [HNOI2001] 软件开发 费用流
[HNOI2001] 软件开发 Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 1938 Solved: 1118[Submit][Status][D ...
- [BZOJ 1221] [HNOI2001] 软件开发 【费用流 || 三分】
题目链接:BZOJ - 1221 题目分析 算法一:最小费用最大流 首先这是一道经典的网络流问题.每天建立两个节点,一个 i 表示使用毛巾,一个 i' 表示这天用过的毛巾. 然后 i 向 T 连 Ai ...
- BZOJ 1221: [HNOI2001] 软件开发【最小费用最大流】
Description 某软件公司正在规划一项n天的软件开发计划,根据开发计划第i天需要ni个软件开发人员,为了提高软件开发人员的效率,公司给软件人员提供了很多的服务,其中一项服务就是要为每个开发人员 ...
- BZOJ 1221 [HNOI2001] 软件开发 费用流_建模
题目描述: 某软件公司正在规划一项n天的软件开发计划,根据开发计划第i天需要ni个软件开发人员,为了提高软件开发人员的效率,公司给软件人员提供了很多的服务,其中一项服务就是要为每个开发人员每天提供 ...
- BZOJ 1221 [HNOI2001] 软件开发(费用流)
[题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=1221 [题目大意] 每天对毛巾都有一定的需求ni,每天可以花f价值每条购买毛巾, 当天 ...
- 【BZOJ 1221】 1221: [HNOI2001] 软件开发 (最小费用流)
1221: [HNOI2001] 软件开发 Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 1581 Solved: 891 Description ...
随机推荐
- Java - 无乱码读写文件
Java读取数据流的时候,一定要指定数据流的编码方式,否则将使用本地环境中的默认字符集. BufferedReader reader = null; String laststr = "&q ...
- 关于Python的多重排序
Python预置的list.sort().sorted()方法可实现各种数组的排序,但支持的只限于一个key,如果要多重排序,目前所知的方法只有自定义了. Help on built-in funct ...
- 使用git bash编译安装sysbench时遇到的坑
Preface When I was compiling the sysbench just now,I encountered some failures in the preced ...
- 「日常训练」Girls and Boys(HDU-1068)
题意 有n个同学,给出同学之间的爱慕关系,选出一个集合使得集合中的人没有爱慕关系.问能选出的最大集合是多少. 分析 二分图的最大独立集. 最大独立集的意思是,在图中选出最多的点,使他们两两之间没有边, ...
- adb获取设备的序列号
用数据线连接手机, 打开开发者模式, 并赋予相关权限, 在CMD命令行输入: adb devices 第一个参数即为设备的序列号, 第二个参数device表示设备的状态是在线.
- Git 与 GitHub
Git 这个年代,不会点Git真不行啦,少年别问问什么,在公司你就知道了~ Git是一个协同开发的工具,主要作用是进行版本控制,而且还能自动检测代码是否发生变化. 一. 安装 下载地址:https:/ ...
- 【Mybatis】 逆向生成工程
前言: 必需学会Maven and SQL基础知识 简介: 通过 Maven, Mybatis 逆向生成 Pojo, Mapper, Example(本章屏蔽了) 工具: JDK8 apache-ma ...
- Visual Studio Code 工具使用教程
软件下载这里就不用讲了,安装完之后: 1.切换中文: 选择扩展 搜索“Language”,在下列选项选择 Chinese (Simplified) Language Pack for Visual S ...
- Siki_Unity_2-1_API常用方法和类详细讲解(下)
Unity 2-1 API常用方法和类详细讲解(下) 任务101&102:射线检测 射线origin + direction:射线检测:射线是否碰撞到物体 (物体需要有碰撞器),碰撞物体的信息 ...
- JDK源码分析:Object.java
一. 序言 Object.java是一切类的基类,所以了解该类有一定的必要 二 .属性及方法分析 方法列表: private static native void registerNatives(); ...