购物网站开发视频教程,wordpress子分类模板,网站开发需要什么工具,wordpress 是免费的嘛正题
AC链接#xff1a; https://www.luogu.org/record/show?rid7949532 大意
有n个月#xff0c;每个月商品价格di#xff0c;需求量Ui。有容量为S的仓库#xff0c;一个商品汇存一个月要m。求最低成本 解题思路
首先是月份做为点#xff0c;成本作为费用#xff0…正题
AC链接 https://www.luogu.org/record/show?rid7949532 大意
有n个月每个月商品价格di需求量Ui。有容量为S的仓库一个商品汇存一个月要m。求最低成本 解题思路
首先是月份做为点成本作为费用需求作为容量。 刚开始想的是专门做一个点作为仓库后来发现其实可以直接向下连边。 然后就是这样构图 然后求费用流就好了 代码
#includecstdio
#includecstring
#includealgorithm
using namespace std;
struct line{int to,w,c,next;
}a[2001];
int tot,n,m,s,t,f[601],ls[601],tail,answer;
int state[601],x,y,w,c,ans,head,pre[601],S;
bool v[601];
void addl(int x,int y,int w,int c)
{a[tot].toy;a[tot].ww;a[tot].cc;a[tot].nextls[x];ls[x]tot;a[tot].tox;a[tot].w0;a[tot].c-c;a[tot].nextls[y];ls[y]tot;
}
bool spfa()
{memset(f,127/3,sizeof(f));memset(v,0,sizeof(v));head0;tail1;v[s]true;state[1]s;f[s]0;while (head!tail){headhead%5001;int xstate[head];for (int qls[x];q;qa[q].next){int ya[q].to;if (a[q].wf[x]a[q].cf[y]){f[y]f[x]a[q].c;pre[y]q;if (!v[y]){v[y]true;tailtail%5001;state[tail]y;}}}v[x]false;}if (f[t]707406378) return 0;else return 1;
}
void upway()
{int k2147483647,nowt;while (now!s){kmin(k,a[pre[now]].w);nowa[pre[now]^1].to;}ansf[t]*k;nowt;answerk;while (now!s){a[pre[now]].w-k;a[pre[now]^1].wk;nowa[pre[now]^1].to;}
}
int main()
{tot1;scanf(%d%d%d,n,m,S);sn1;tn2;for (int i1;in;i)scanf(%d,x),addl(i,t,x,0);//完成订单for (int i1;in;i)scanf(%d,x),addl(s,i,1e9,x);//进货for (int i1;in;i)addl(i,i1,S,m);//存while (spfa()){upway();}printf(%d,ans);
}