http://www.elijahqi.win/archives/2898
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
参考这篇他的弱化版
https://blog.csdn.net/elijahqi/article/details/78906796
#include<cmath>
#include<cstdio>
#include<cctype>
#include<algorithm>
#define M 10010
#define N 1010
#define eps 1e-7
#define inf 0x3f3f3f3f3
using namespace std;
inline char gc(){
static char now[1<<16],*S,*T;
if (T==S){T=(S=now)+fread(now,1,1<<16,stdin);if (T==S) return EOF;}
return *S++;
}
inline int read(){
int x=0;char ch=gc();
while(!isdigit(ch)) ch=gc();
while(isdigit(ch)) x=x*10+ch-'0',ch=gc();
return x;
}
double a[M][N];int n,m;
inline void pivot(int e,int l){
static double t;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) continue;
t=a[i][e];a[i][e]=0;
for (int j=0;j<=n;++j) a[i][j]-=t*a[l][j];
}
}
inline void simplex(){
while(1){
static int l,e;l=e=0;
for (int i=1;i<=n;++i)
if (a[0][i]>eps) {e=i;break;}
if (!e) return;static double mn;mn=inf;
for (int i=1;i<=m;++i)
if (a[i][e]>eps&&mn>a[i][0]/a[i][e]) mn=a[i][0]/a[i][e],l=i;
if (!l) return;pivot(e,l);
}
}
int main(){
freopen("bzoj3265.in","r",stdin);
n=read();m=read();
for (int i=1;i<=n;++i) a[0][i]=read();
for (int i=1;i<=m;++i){
static int s,t,k;k=read();
for (int owo=1;owo<=k;++owo){
s=read();t=read();
for (int j=s;j<=t;++j) a[i][j]=1;
}a[i][0]=read();
}simplex();
printf("%d\n",-(int)a[0][0]);
return 0;
}