# 2009国家集训队 employ人员雇佣

3
3 5 100
0 6 1
6 0 2
1 2 0

## Sample Output

1
【数据规模和约定】
20%的数据中N<=10
50%的数据中N<=100
100%的数据中 N<=1000， Ei,j<=maxlongint, Ai<=maxlongint

solution

  1 #include<cstdio>
2 #include<cstring>
3 #include<queue>
4 #include<iostream>
5 #define mem(a,b) memset(a,b,sizeof(a))
6 #define ll long long
7 #define dd double
8 using namespace std;
9 const int INF=(1<<31)-1;
10 const int N=2006;
11 inline int minn(int a,int b){return a<b?a:b;}
12 struct son
13 {
14     int u,v,next;
15     int w;
16 };
17 son a1[3000006];
18 int first[3000006],e;
19 void addbian(int u,int v,int w)
20 {
21     a1[e].v=v;
22     a1[e].w=w;
23     a1[e].u=u;
24     a1[e].next=first[u];
25     first[u]=e++;
26 }
27 void Link(int u,int v,int w)
28 {
31 }
32 void Match(int u,int v,int w)
33 {
36 }
37
38 int n,S,T;
39 int sumE;
40 int A[N];
41 int E[N][N];
42 int sum[N];
43
44 int dui[10000001],he,en;
45 inline void push(int x){dui[++en]=x;}
46 inline bool empty(){return en>=he?0:1;}
47 inline int top(){return dui[he];}
48 inline void pop(){++he;}
49 inline void clear(){he=1;en=0;}
50
51 int dep[N];
52 int bfs()
53 {
54     mem(dep,0);clear();
55     dep[S]=1;push(S);
56     while(!empty())
57     {
58         int now=top();pop();
59         for(int i=first[now];i!=-1;i=a1[i].next)
60         {
61             int temp=a1[i].v;
62             if(!a1[i].w||dep[temp])continue;
63             dep[temp]=dep[now]+1;
64             push(temp);
65             if(temp==T)return 1;
66         }
67     }
68     return 0;
69 }
70
71 int dfs(int x,int val)
72 {
73     if(x==T)return val;
74     int val2=val,k;
75     for(int i=first[x];i!=-1;i=a1[i].next)
76     {
77         int temp=a1[i].v;
78         if(!a1[i].w||dep[temp]!=dep[x]+1||!val2)continue;
79         k=dfs(temp,minn(val2,a1[i].w));
80         if(!k){dep[temp]=0;continue;}
81         a1[i].w-=k;a1[i^1].w+=k;val2-=k;
82     }
83     return val-val2;
84 }
85
86 int Dinic()
87 {
88     int ans=0;
89     while(bfs())
90       ans+=dfs(S,INF);
91     return ans;
92 }
93
94 int main(){
95     mem(first,-1);
96     scanf("%d",&n);
97     for(int i=1;i<=n;++i)scanf("%d",&A[i]);
98     for(int i=1;i<=n;++i)
99       for(int j=1;j<=n;++j)
100       {
101             scanf("%d",&E[i][j]);
102             sum[i]+=E[i][j];
103         }
104
105     for(int i=1;i<=n;++i)
106       for(int j=i+1;j<=n;++j)
107         sumE+=E[i][j];
108     sumE*=2;
109
110     S=0;T=n+1;
111
112     for(int i=1;i<=n;++i)
114     for(int i=1;i<=n;++i)
123 }