Topic Description
Transfer Door solving
Same as the volunteer recruiting.
Simplex Bare title code
#include <algorithm> #include <iostream> #include <cstring> #include <cstdio> #include <
Cmath> using namespace std;
#define N 1005 #define M 10005 const double eps=1e-9;
const double INF=1E18;
int n,m,k,l,r;
Double A[m][n],b[m],c[n],ans;
void pivot (int l,int e) {b[l]/=a[l][e];
for (int i=1;i<=n;++i) if (i!=e) a[l][i]/=a[l][e];
A[l][e]=1.0/a[l][e];
for (int i=1;i<=m;++i) if (I!=l&&fabs (a[i][e)) >eps) {b[i]-=b[l]*a[i][e];
for (int j=1;j<=n;++j) if (j!=e) a[i][j]-=a[l][j]*a[i][e];
A[i][e]=-a[l][e]*a[i][e];
} Ans+=b[l]*c[e];
for (int i=1;i<=n;++i) if (i!=e) c[i]-=c[e]*a[l][i];
C[e]=-c[e]*a[l][e];
} void Simplex () {while (1) {int E;
for (E=1;e<=n;++e) if (c[e]>eps) break;
if (e==n+1) break;
Double Min=inf,t;int L; for (int i=1;i<=m;++i) if (a[i][e]>eps&& (t=b[i]/a[i][e)) <min) {min=t;
L=i;
} pivot (l,e);
int main () {scanf ("%d%d", &n,&m);
for (int i=1;i<=n;++i) scanf ("%lf", &c[i));
for (int i=1;i<=m;++i) {scanf ("%d", &k);
while (k--) {scanf ("%d%d", &l,&r);
for (int j=l;j<=r;++j) ++A[I][J];
} scanf ("%lf", &b[i]);
} simplex ();
printf ("%.0lf\n", ans); }