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 ...
随机推荐
- UWP 应用中的Back button(TitleBar) 的处理
后退按钮是一项系统提供的 UI 提示,可以在后退堆栈或用户导航历史记录中支持向后导航. 用起来其实也是很简单的,只需要在App.xaml.cs 中修改(添加)如下红色代码,便可实现.. sealed ...
- 2-19-使用apache搭建web网站
1 搭建一台测试web服务器 案例: 部门内部搭建一台WEB服务器,采用的IP地址和端口为192.168.10.34:80,首页采用index.html 文件.管理员E-mail地址为 xuegod@ ...
- jquery 访问cookie
<!DOCTYPE html><html lang="en" xmlns="http://www.w3.org/1999/xhtml"> ...
- jquery开关灯
<!DOCTYPE html><html lang="en" xmlns="http://www.w3.org/1999/xhtml"> ...
- 从PRISM开始学WPF(八)导航Navigation?
原文:从PRISM开始学WPF(八)导航Navigation? 0x6Navigation Basic Navigation Prism中的Navigation提供了一种类似导航的功能,他可以根据用户 ...
- Windows 10开发基础——网络编程
主要内容: HttpClient类 Socket通信 WCF通信 HttpClient类 在UWP中可以用来进行网络通信的HttpClient类有两个,System.Net.Http.Htt ...
- 超详细SQL SERVER 2016跨网段和局域网发布订阅配置图解和常见问题
原文:超详细SQL SERVER 2016跨网段和局域网发布订阅配置图解和常见问题 转载标明出处:http://blog.csdn.net/u012861467 前方高能,要有点耐心,图片较多,注意在 ...
- C#根据对象的指定字段去除重复值
PersonInfo类: public class PersonInfo { public int Index; public string Name; public override string ...
- memcached的使用一
1.安装memcached 需要一个memcache.exe文件,打开cmd窗口,切换到可执行文件目录,执行memcache -的install命令. 2.连接服务 做测试可以打开电脑的telnet ...
- 【Windows Universal Platform】只是学习笔记 - 开始
我是初学,之前没有windows/windows phone的应用开发经验:开博的目的只是记录和督促自己学习. 心血来潮也好,或是个人喜好的原因,想学着自己开发APP了(PS:以前做过web 开发) ...