BZOJ 1061:志愿者招募(单纯型)
题意
中文题意。
思路
单纯型模板题。
单纯型用来解决线性规划问题。
留坑待填。
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
const int N = 1e3 + 11;
const int M = 1e4 + 11;
const double eps = 1e-8;
const double inf = 1000000000;
int n, m;
double cof[M][N], day[N], c[M];
void pivot(int id, int pos, double &ans) {
	c[id] /= cof[id][pos];
	cof[id][pos] = 1 / cof[id][pos];
	for(int i = 1; i <= n; i++)
		if(i != pos) cof[id][i] *= cof[id][pos];
	for(int i = 1; i <= m; i++) {
		if(i != id && fabs(cof[i][pos]) > eps) {
			c[i] -= cof[i][pos] * c[id];
			for(int j = 1; j <= n; j++)
				if(j != pos)
					cof[i][j] -= cof[i][pos] * cof[id][j];
			cof[i][pos] = -cof[i][pos] * cof[id][pos];
		}
	}
	ans += day[pos] * c[id];
	for(int i = 1; i <= n; i++)
		if(i != pos) day[i] -= day[pos] * cof[id][i];
	day[pos] = -day[pos] * cof[id][pos];
}
double simplex() {
    double ans = 0;
	while(true) {
		int pos, id;
		for(pos = 1; pos <= n; pos++) if(day[pos] > eps) break;
		if(pos == n + 1) return ans;
		double tmp = inf;
		for(int i = 1; i <= m; i++)
			if(cof[i][pos] > eps && c[i] / cof[i][pos] < tmp)
				tmp = c[i] / cof[i][pos], id = i;
		if(tmp == inf) return inf;
		pivot(id, pos, ans);
	}
	return ans;
}
int main() {
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; i++) scanf("%lf", &day[i]);
	for(int i = 1; i <= m; i++) {
		int s, t;
		scanf("%d%d%lf", &s, &t, &c[i]);
		for(int j = s; j <= t; j++) cof[i][j] = 1;
	}
	double ans = simplex();
	printf("%lld\n", LL(ans + 0.5));
	return 0;
}
												
											BZOJ 1061:志愿者招募(单纯型)的更多相关文章
- bzoj 1061 志愿者招募(最小费用最大流)
		
[Noi2008]志愿者招募 Time Limit: 20 Sec Memory Limit: 162 MBSubmit: 3792 Solved: 2314[Submit][Status][Di ...
 - BZOJ 1061 志愿者招募(最小费用最大流)
		
题目链接:http://61.187.179.132/JudgeOnline/problem.php?id=1061 题意:申奥成功后,布布经过不懈努力,终于 成为奥组委下属公司人力资源部门的主管.布 ...
 - BZOJ 1061 志愿者招募 最小费用流&&线性规划建模
		
题目链接: https://www.lydsy.com/JudgeOnline/problem.php?id=1061 题目大意: 申奥成功后,布布经过不懈努力,终于成为奥组委下属公司人力资源部门的主 ...
 - bzoj 1061 志愿者招募 有上下界费用流做法
		
把每一天看作一个点,每一天的志愿者数目就是流量限制,从i到i+1连边,上下界就是(A[i],+inf). 对于每一类志愿者,从T[i]+1到S[i]连边,费用为招募一个志愿者的费用,流量为inf.这样 ...
 - BZOJ 1061 志愿者招募
		
http://www.lydsy.com/JudgeOnline/problem.php?id=1061 思路:可以用不等式的改装变成费用流. 将不等式列出,如果有负的常数,那么就从等式连向T,如果是 ...
 - bzoj 1061 志愿者招募 费用流
		
详见BYV的博客,写的非常全面https://www.byvoid.com/blog/noi-2008-employee /************************************** ...
 - bzoj [Noi2008] 1061 志愿者招募 单纯形
		
[Noi2008]志愿者招募 Time Limit: 20 Sec Memory Limit: 162 MBSubmit: 5437 Solved: 3267[Submit][Status][Di ...
 - BZOJ 3265 志愿者招募加强版(单纯形)
		
3265: 志愿者招募加强版 Time Limit: 20 Sec Memory Limit: 512 MBSubmit: 848 Solved: 436[Submit][Status][Disc ...
 - BZOJ 3265 志愿者招募增强版 单
		
标题效果:同1061 只是间隔为每种类型的志愿工作是多级 这是卡网络流量?未知 所有在所有的1061您将可以更改为在稍微改变- - #include <cmath> #include &l ...
 - BZOJ.3265.志愿者招募加强版(费用流SPFA)
		
题目链接 见上题. 每类志愿者可能是若干段,不满足那个...全幺模矩阵(全单位模矩阵)的条件,所以线性规划可能存在非整数解. 于是就可以用费用流水过去顺便拿个rank2 233. //20704kb ...
 
随机推荐
- 形态学-扩大-C代码
			
直接在代码,难.他们明白: void MorhpolotyDilate_ChenLee(unsigned char* pBinImg, int imgW, int imgH, Tpoint* mask ...
 - 辛星与您彻底解决CSS浮子(下一个)
			
上述博客文章,我们解释如何使用CSS浮子,这是一个看我们如何解释清除CSS浮子.其实CSS浮动是很清楚easy,只需要使用clear它财产,至于如何利用好它.很多人可能会表决雾,我是个新手的时候还经常 ...
 - XF 按钮控件
			
<?xml version="1.0" encoding="utf-8" ?> <ContentPage xmlns="http:/ ...
 - 最简单的IdentityServer实现——IdentityServer
			
1.新建项目 新建ASP .Net Core项目IdentityServer.EasyDemo.IdentityServer,选择.net core 2.0 1 2 引用IdentitySer ...
 - AY的Dapper研究学习-继续深入-C#开发-aaronyang技术分享
			
原文:AY的Dapper研究学习-继续深入-C#开发-aaronyang技术分享 ====================www.ayjs.net 杨洋 wpfui.com ...
 - 自定义LISTBOX内子项为checkbox或者radio时,关于IsChecked绑定
			
IsChecked="{Binding IsSelected, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}&q ...
 - xml 封装类
			
public static class XmlHelper { public static T FromXmlFile<T>(this string filePath) where T : ...
 - C#高性能大容量SOCKET并发(三):接收、发送
			
原文:C#高性能大容量SOCKET并发(三):接收.发送 异步数据接收有可能收到的数据不是一个完整包,或者接收到的数据超过一个包的大小,因此我们需要把接收的数据进行缓存.异步发送我们也需要把每个发送的 ...
 - 【Windows10 IoT开发系列】Powershell命令行实用程序
			
原文:[Windows10 IoT开发系列]Powershell命令行实用程序 更新帐户密码: 强烈建议你更新默认的管理员帐户密码.若要更新帐户密码,你可以发出以下命令: net user Admin ...
 - JS获取a标签的Href 内容
			
<script type="text/javascript">function getHref(obj){ alert(obj.href);} </script& ...