Codeforces 724 E Goods transportation】的更多相关文章

Description 有 \(n\) 个点,每个点有一个入流和出流,每个点与编号比它大的点连边,容量为 \(c\) ,求最大流. Sol DP. 这种特殊的图可以DP,把最大流转化成最小割. 最小割就是 \(\sum s_i,i\in S + \sum p_j,j \in T + c \sum [i \in S][j\in T]\) . 最后一个式子其实就是 \(S\) 与 \(T\) 的割边. \(f[i][j]\) 表示前 \(i\) 个点有 \(j\) 个点 \(\in S\) 转移就是…
[题目链接]:http://codeforces.com/problemset/problem/724/E [题意] 有n个城市; 这个些城市每个城市有pi单位的物品; 然后已知每个城市能卖掉si单位单位的物品: 且每个城市i能向城市j最多运送c单位的物品(这里j严格大于i); 问你最多能在这n个城市里面卖掉多少单位的物品; [题解] 可以转化为最大流模型; 虚拟一个起点s和源点t; 在s和n个城市之间分别建n条边pi; 在n个城市和t之间分别建n条边si; 在n个城市之间(x,y)建n*(n-…
E. Goods transportation 题目连接: http://codeforces.com/contest/724/problem/E Description There are n cities located along the one-way road. Cities are numbered from 1 to n in the direction of the road. The i-th city had produced pi units of goods. No mo…
Goods transportation time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output There are n cities located along the one-way road. Cities are numbered from 1 to n in the direction of the road. The i-…
E - Goods transportation 思路:这个最大流-> 最小割->dp好巧妙哦. #include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mk make_pair #define PII pair<int, int> #define PLI pair<LL, int> #define ull unsigned long lo…
[codeforces724E]Goods transportation 试题描述 There are n cities located along the one-way road. Cities are numbered from 1 to n in the direction of the road. The i-th city had produced pi units of goods. No more than si units of goods can be sold in the…
[题目链接] http://codeforces.com/problemset/problem/724/E [题目大意] 每个城市有pi的物品可以运出去卖,si个物品可以买, 编号小的城市可以往编号大的城市最多运送c的物品,问最多有多少物品可以被买卖 [题解] 源点向每个城市引pi的流,每个城市向汇点引si的流, 小编号的城市往大编号的城市引c的流,那么全图的最大流就是答案, 但是数据量过大,我们考虑转化. 因为最大流等于最小割,我们发现对于这个图,最后每个点不是跟s连就是跟t连, 那么我们设d…
妙啊 首先暴力建图跑最大流非常简单,s向每个i连流量为p[i]的边,每个i向t连流量为s[i]的边,每个i向j连流量为c的边(i<j),但是会又T又M 考虑最大流=最小割 然后dp求最小割,设f[i][j]为割到第i个点,有j条连着s(因为最小割中一个点不是连s就是连t),转移是 \[ f[i][j]=min(f[i-1][j]+1*j*c+p[i],f[i-1][j-1]+s[i]) \] #include<iostream> #include<cstdio> using…
题目链接:http://codeforces.com/contest/724/problem/E 题目大意: 有n个城市,每个城市有pi件商品,最多能出售si件商品,对于任意一队城市i,j,其中i<j,可以从城市i往j运输最多c件商品. 求最多一共能卖出多少件商品.  n<=10000 解法一(官方解法): 构造网络流,因为边太多,不可能直接跑最大流. 根据图的特殊性,考虑用dp求解最小割. 状态:dp[i,j]表示前i个中有j个和源点相通的最小割. 转移:如果第i个点不和源点相连,那么pi这…
题目链接: http://codeforces.com/contest/724 A. Checking the Calendar time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given names of two days of the week. Please, determine whether it is…