传送门


一个人多段区间,一样....

不过国家队论文上说这道题好像不能保证整数解....

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
const int N=,M=1e4+;
const double INF=1e15,eps=1e-;
inline int read(){
char c=getchar();int x=,f=;
while(c<''||c>''){if(c=='-')f=-;c=getchar();}
while(c>=''&&c<=''){x=x*+c-'';c=getchar();}
return x*f;
} int n,m;
double a[M][N];
int q[N];
void Pivot(int l,int e){
double t=a[l][e];a[l][e]=;
for(int j=;j<=n;j++) a[l][j]/=t;
int p=;
for(int j=;j<=n;j++) if(abs(a[l][j])>eps) q[++p]=j;
for(int i=;i<=m;i++) if(i!=l && abs(a[i][e])>eps){
double t=a[i][e];a[i][e]=;
for(int j=;j<=p;j++) a[i][q[j]]-=t*a[l][q[j]];
}
}
void simplex(){
while(true){
int l=,e=; double mn=INF;
for(int j=;j<=n;j++) if(a[][j]>eps) {e=j;break;}
if(!e) return;
for(int i=;i<=m;i++)
if(a[i][e]>eps && a[i][]/a[i][e]<mn) {mn=a[i][]/a[i][e];l=i;}
if(!l) return;//unbounded
Pivot(l,e);
}
}
int main(){
freopen("in","r",stdin);
n=read();m=read();
for(int i=;i<=n;i++)a[][i]=read();
for(int i=;i<=m;i++){
int k=read();
while(k--){
int l=read(),r=read();
for(int j=l;j<=r;j++) a[i][j]=;
}
a[i][]=read();
}
simplex();
printf("%d",int(-a[][]+0.5));
}

最新文章

  1. Odoo Graph 指定默认 类型
  2. Chrome54安装最新版Flash版本办法
  3. 解析window.open链接的参数
  4. qt-5.6.0 移植之实现板子与ubuntu主机通过网络进行文件传输
  5. 对只转发结果集的无效操作 first
  6. Java for LeetCode 033 Search in Rotated Sorted Array
  7. java几道简单的面试题目
  8. VBS_For Each...Next
  9. 图片加载js类库
  10. 每日一练--C语言--串
  11. C语言运算符优先级表
  12. 时间处理总结(二)oracle
  13. Ant自动构建
  14. IIS7.0发布后关于&quot;不能在此路径中使用此配置节”的解决办法
  15. selenium框架与chrome浏览器的不兼容问题
  16. 解决弹出蒙层滑动穿透问题-vue
  17. inittab文件剖析[CentOS 5.X](第二版)
  18. hibernate关系映射
  19. dubbo协议报文格式
  20. jvm排查问题常用命令及注释

热门文章

  1. python3 爬淘女郎
  2. Spark算子--union、intersection、subtract
  3. final、finally、finalize
  4. python利用socketserver实现并发套接字功能
  5. phpcms v9——工作需要【套模板】
  6. Java hashtable和hastmap的区别
  7. pthread_cond_wait的spurious wakeup问题
  8. html静态页面乱码
  9. Jade报错:Invalid indentation,you can use tabs or spaces but not both问题
  10. 一、Python表达式基础