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 long
using namespace std; const int N = 1e4 + ;
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + ; int n, c, cur, p[N], s[N];
LL dp[][N];
int main() {
scanf("%d%d", &n, &c);
for(int i = ; i <= n; i++) scanf("%d", &p[i]);
for(int i = ; i <= n; i++) scanf("%d", &s[i]);
memset(dp[cur], INF, sizeof(dp[cur]));
dp[cur][] = ;
for(int i = ; i <= n; i++) {
cur ^= ;
memset(dp[cur], INF, sizeof(dp[cur]));
dp[cur][] = dp[cur^][] + p[i];
for(int j = ; j < i; j++) {
dp[cur][j] = min(dp[cur^][j] + 1ll*j*c + p[i], dp[cur^][j-] + s[i]);
}
dp[cur][i] = dp[cur^][i-] + s[i];
}
LL ans = INF;
for(int i = ; i <= n; i++) ans = min(ans, dp[cur][i]);
printf("%lld\n", ans);
return ;
} /*
*/

Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) E - Goods transportation 最大流转最小割转dp的更多相关文章

  1. CF Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined)

    1. Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) B. Batch Sort    暴力枚举,水 1.题意:n*m的数组, ...

  2. Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined)D Dense Subsequence

    传送门:D Dense Subsequence 题意:输入一个m,然后输入一个字符串,从字符串中取出一些字符组成一个串,要求满足:在任意长度为m的区间内都至少有一个字符被取到,找出所有可能性中字典序最 ...

  3. Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) B. Batch Sort

    链接 题意:输入n,m,表示一个n行m列的矩阵,每一行数字都是1-m,顺序可能是乱的,每一行可以交换任意2个数的位置,并且可以交换任意2列的所有数 问是否可以使每一行严格递增 思路:暴力枚举所有可能的 ...

  4. Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) C. Ray Tracing

    我不告诉你这个链接是什么 分析:模拟可以过,但是好烦啊..不会写.还有一个扩展欧几里得的方法,见下: 假设光线没有反射,而是对应的感应器镜面对称了一下的话 左下角红色的地方是原始的的方格,剩下的三个格 ...

  5. Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) C.Ray Tracing (模拟或扩展欧几里得)

    http://codeforces.com/contest/724/problem/C 题目大意: 在一个n*m的盒子里,从(0,0)射出一条每秒位移为(1,1)的射线,遵从反射定律,给出k个点,求射 ...

  6. Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) E. Goods transportation (非官方贪心解法)

    题目链接:http://codeforces.com/contest/724/problem/E 题目大意: 有n个城市,每个城市有pi件商品,最多能出售si件商品,对于任意一队城市i,j,其中i&l ...

  7. Codeforces Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) A. Checking the Calendar(水题)

    传送门 Description You are given names of two days of the week. Please, determine whether it is possibl ...

  8. Codeforces Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) B. Batch Sort(暴力)

    传送门 Description You are given a table consisting of n rows and m columns. Numbers in each row form a ...

  9. Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) B

    Description You are given a table consisting of n rows and m columns. Numbers in each row form a per ...

随机推荐

  1. sleep php函数

    <?php echo date('h:i:s') . "<br />"; //暂停 10 秒 sleep(10); //重新开始 echo date('h:i:s ...

  2. uboot&kernel&system

  3. C/C++预处理宏的总结

    1.定义顺序的无关性 #define PI 3.14 #define TWO_PI  2*PI 这两句谁前谁后无所谓,因为预处理器不断迭代来实现宏替换,直到源文件中没有宏了才停止. 2. 宏变量变成字 ...

  4. VS工程使用Git时的过滤文件

    1.解决方案必须保留的文件sln和suo,需要过滤的文件为sdfVisual Studio.NET采用两种文件类型(.sln和.suo)来存储特定于解决方案的设置,它们总称为解决方案文件.为解决方案资 ...

  5. net-speeder

    有的同学反映自己的搬瓦工速度慢,丢包率高.这其实和你的网络服务提供商有关.据我所知一部分上海电信的同学就有这种问题.那么碰到了坑爹的网络服务商,我们应该怎么办呢? duangduang~~~~~~有请 ...

  6. Debian9(8)下python3和python2同时安装如何使用pip

    在bash下Python会调用python2.x python3会调用python3.x 如果使用pip install命令安装模块会安装python2的模块. 而python3的pip命令使用的是p ...

  7. Elasticsearch Java API 配置测试

    Elasticsearch1.X,2.X,5.X随着版本的迭代,除了系统升级,Java API也做了相对较大的调整,也就是说,1.X的API在2.X以及5.X乃至未来6.X版本都不是通用的. 本例子使 ...

  8. Centos 7 下搭建 Dokuwiki

    Centos 7 下搭建 Dokuwiki # Dokuwiki 是php的,所以要先搭建php环境,下载 apache和php,第1.2步下载完,相关的依赖都会下载## 1.下载 httpdyum ...

  9. 【CodeForces】679 B. Bear and Tower of Cubes

    [题目]B. Bear and Tower of Cubes [题意]有若干积木体积为1^3,2^3,...k^3,对于一个总体积X要求每次贪心地取<=X的最大积木拼上去(每个只能取一次)最后总 ...

  10. js面向对象的几种常见写法

    下面是一个简单的js对象:定义Circle类,拥有成员变量r,常量PI和计算面积的成员函数area(),常用为第一种和第三种. 1.工厂方式 var Circle = function() { var ...