题目的意思就就是首先给出点的个数,在给出边的个数,然后给出每条边的费用.
然后给出的两个数字,是要从点1运到点n的物品数量.
还有每条边的容量(所有边容量一样)
因为是无向图,所以我们用邻接表存,在用最小费用最大流的算法直接算出最小费用.
但如果算出来的最大流小于我们要运的数量,说明运不过去,,
ac代码:
#include<stdio.h>
#include<string.h>
#include<queue>
#define ll long long
using namespace std;
const ll INF = 1000000000000005;
const int N = 105;
const int M = 5005;
const int K = 20100;
ll cap[K];
ll flow[K];
ll cost[K];
ll nex[K];
ll first[M];
ll u[K];
ll v[K];
int p[N];
ll a[M];
ll b[M];
ll g[M];
ll n,m, num , maxcap;
ll c, f ;
int e;
void add(ll s , ll t ,ll c ,ll co) {
u[e] = s;
v[e] = t;
nex[e] = first[u[e]];
first[u[e]] = e;
cap[e] = c;
cost[e] = co;
e++;
u[e] = t;
v[e] = s;
nex