博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
BZOJ3265: 志愿者招募加强版(线性规划)
阅读量:6974 次
发布时间:2019-06-27

本文共 1742 字,大约阅读时间需要 5 分钟。

Time Limit: 20 Sec  Memory Limit: 512 MB
Submit: 809  Solved: 417
[][][]

Description

Input

Output

Sample Input

3 3
2 3 4
1 1 2 2
1 2 3 5
1 3 3 2

Sample Output

14

HINT

Source

 

这题是来搞笑的么??

除了多循环几次之外和原版有啥区别?qwq、

#include
#include
#include
#define LL long long using namespace std;const int MAXN = 51, INF = 1e9 + 10;const double eps = 1e-8;inline int read() { char c = getchar();int x = 0,f = 1; while(c < '0' || c > '9'){
if(c == '-')f = -1;c = getchar();} while(c >= '0' && c <= '9'){x = x * 10 + c - '0',c = getchar();} return x * f;}int N, M;LL a[10001][1001];void Pivot(int l, int e) { double t = a[l][e]; a[l][e] = 1; for(int i = 0; i <= N; i++) a[l][i] /= t; for(int i = 0; i <= M; i++) { if(i != l && abs(a[i][e]) > eps) { t = a[i][e]; a[i][e] = 0; for(int j = 0; j <= N; j++) a[i][j] -= a[l][j] * t; } }}bool simplex() { while(1) { int l = 0, e = 0; double mn = INF; for(int i = 1; i <= N; i++) if(a[0][i] > eps) {e = i; break;} if(!e) break; for(int i = 1; i <= M; i++) if(a[i][e] > eps && a[i][0] / a[i][e] < mn) mn = a[i][0] / a[i][e], l = i; Pivot(l, e); } return 1;}int main() {// freopen("a.in", "r", stdin); srand(19260817); N = read(); M = read(); for(int i = 1; i <= N; i++) a[0][i] = read(); for(int i = 1; i <= M; i++) { int K = read(); while(K--) { int S = read(), T = read(); for(int j = S; j <= T; j++) a[i][j] = 1; } int C = read(); a[i][0] = C; } simplex(); printf("%lld", -a[0][0]); return 0;}

 

转载地址:http://coesl.baihongyu.com/

你可能感兴趣的文章
Oracle数据库语句大全
查看>>
系统知识点笔记
查看>>
Gradle 2.3 发布
查看>>
数据库内核月报 - 2015 / 10-MySQL · 特性分析 · MySQL权限存储与管理
查看>>
Swift教程_零基础学习Swift完整实例(五)_swift完整实例(构建数据层)
查看>>
[Angularjs]asp.net mvc+angularjs+web api单页应用
查看>>
仿Linux中的cp操作
查看>>
【ANDROID游戏开发十五】关于ANDROID 游戏开发中 ONTOUCHEVENT() 触屏事件的性能优化笔记!...
查看>>
移动端web开发 chapter 1 – introduction
查看>>
获取时间的方法及常用时间类
查看>>
Git忽略文件
查看>>
如何删除或重置spfile中的参数
查看>>
Spring Boot 之 HelloWorld详解
查看>>
【RAC】如何修改vip 或者vip 对应的hostname
查看>>
Sql Server之旅——第三站 解惑那些背了多年聚集索引的人
查看>>
【LINUX】磁盘格式化 创建文件系统
查看>>
expect使用详解
查看>>
IOS(CGGeometry)几何类方法总结
查看>>
Quart2D setNeedsDisplay
查看>>
Android TextView点击效果
查看>>