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 ...
随机推荐
- 使用WPF技术模拟手机界面
原文:使用WPF技术模拟手机界面 1. 前言 WPF(Windows Presentation Foundation),即"Windows呈现基础",它的目的非常明确,就是用来把数 ...
- 如何加入该网站for Linux(绑定域名)
[路径跟踪配置由阿里云提供的标准环境的路径为准,假设你单独安装.请根据实际的安装路径配置]. 1.cd /alidata/server/httpd/conf/vhosts/ 进入绑定域名所在文件夹 ...
- [转]Nodejs开发框架Express4.x开发手记
Express: ?web application framework for?Node.js? Express 是一个简洁.灵活的 node.js Web 应用开发框架, 它提供一系列强大的特性,帮 ...
- postgresql 自带函数
替换函数 SELECT replace('abcdefabcdef', 'cd', 'XX') 得到 abXXefabXXef ------------------------------------ ...
- node.js开发笔记之EXPRESS与EJS之ejs标签v20140329
本次记录下ejs的渲染标签 node既然是javascrip的,那么很多在前端执行代码的方式都可以放在后台从而达到无缝连接! 比如 var ygxx = function(){document.get ...
- WPF 多路绑定
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threa ...
- DateTime格式转换结果
Console.WriteLine(string.Format("ToLongDateString:{0}", DateTime.Now.ToLongDateString())); ...
- 安装CUDA和cuDNN
GPU和CPU区别 1,CPU主要用于处理通用逻辑,以及各种中断事物 2,GPU主要用于计算密集型程序,可并行运作: NVIDIA 的 GeForce 显示卡系列采用 GPU 特性进行快速计算,渲染电 ...
- SQL Server 2016新特性:DROP IF EXISTS
原文:SQL Server 2016新特性:DROP IF EXISTS 在我们写T-SQL要删除某个对象(表.存储过程等)时,一般会习惯先用IF语句判断该对象是否存在,然后DROP,比如: 旧 ...
- PHP MYSQL 获取记录总数
$qid = mysql_query(“SELECT count(aid) as total FROM table group by aid “);//你的查询 $res = mysql_fetch_ ...