【BZOJ4145】[AMPPZ2014]The Prices【状压DP】【背包】
来源:互联网 发布:python macd指标 宽距 编辑:程序博客网 时间:2024/06/05 18:00
【题目链接】
【tunix的题解】
/* Telekinetic Forest Guard */#include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int maxn = 105, maxm = 18, maxs = 1 << 16, inf = 0x3f3f3f3f;int n, m, dp[maxn][maxs], w[maxn][maxm], d[maxn], bin[maxm];inline int iread() {int f = 1, x = 0; char ch = getchar();for(; ch < '0' || ch > '9'; ch = getchar()) f = ch == '-' ? -1 : 1;for(; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';return f * x;}int main() {bin[0] = 1;for(int i = 1; i <= 16; i++) bin[i] = bin[i - 1] << 1;n = iread(); m = iread();for(int i = 1; i <= n; i++) {d[i] = iread();for(int j = 1; j <= m; j++) w[i][j] = iread();}int S = 1 << m;for(int s = 0; s < S; s++) dp[0][s] = inf;dp[0][0] = 0;for(int i = 1; i <= n; i++) {for(int s = 0; s < S; s++) dp[i][s] = dp[i - 1][s] + d[i];for(int s = 0; s < S; s++) for(int j = 1; j <= m; j++) {int ns = s | bin[j - 1];if(s != ns) dp[i][ns] = min(dp[i][ns], dp[i][s] + w[i][j]);}for(int s = 0; s < S; s++) dp[i][s] = min(dp[i][s], dp[i - 1][s]);}printf("%d\n", dp[n][S - 1]);return 0;}
0 0
- 【BZOJ4145】[AMPPZ2014]The Prices【状压DP】【背包】
- 【bzoj4145】【AMPPZ2014】【The Prices】【状压dp】
- bzoj4145 [AMPPZ2014]The Prices 状压dp
- bzoj4145 [AMPPZ2014]The Prices (状压DP)
- 【bzoj4145】[AMPPZ2014]The Prices
- 【AMPPZ2014】【BZOJ4145】The Prices
- [BZOJ4145] [AMPPZ2014]The Prices
- bzoj4145 [AMPPZ2014]The Prices
- [bzoj4145][AMPPZ2014]The Prices
- BZOJ4145: [AMPPZ2014]The Prices
- BZOJ 4145 AMPPZ2014 The Prices 状压DP
- 4145: [AMPPZ2014]The Prices 状压DP
- bzoj 4145: [AMPPZ2014]The Prices 状压dp
- 【BZOJ4145】【装压DP】 The Prices 题解
- bzoj 4145 [AMPPZ2014]The Prices dp
- BZOJ 4145: [AMPPZ2014]The Prices
- 状压BZOJ 4145 The Prices题解
- 【AMPPZ2014】【BZOJ4143】The Lawyer
- Java 性能优化
- WGS84、GCJ-02(火星坐标)、百度坐标,Web墨卡托坐标
- OC与javascript进行交互
- Android的IPC机制(二)——AIDL实现原理简析
- 嵌入式操作系统内核原理和开发(总结篇)
- 【BZOJ4145】[AMPPZ2014]The Prices【状压DP】【背包】
- Qt之表单布局(QFormLayout)
- 《c++primer 》string *pstr = new string; *pstr = str;的疑问
- Orange’s学习笔记(一)
- 春哥来了
- 在Eclipse中安装Subclipse
- tomcat多工程SSL双向认证的实现(每个端口对应一个工程,每个工程有各自双向的证书)
- Ubuntu配置NFS服务器与客户端
- 【Android Studio快捷键】之导入相应包声明(import packages)