bzoj3265 志愿者招募加强版

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;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值