bzoj4145 [AMPPZ2014]The Prices
来源:互联网 发布:小明发布台湾永久域名 编辑:程序博客网 时间:2024/05/16 14:08
分析:我真是弱的不行。。设f[i][j]表示前i个商店的购买状态为j的最小花销。。明显有f[i][j]=f[i-1][j]+d[i];枚举没有买的物品k,f[i][j|(1<<k-1)]=max(f[i][j]+cost[i][j]);最后还要看在i商店的买卖是否划算..f[i][j]=min(f[i][j],f[i-1][j]);
#include<cstdio>#include<algorithm>#include<cstring>#include<cmath>#define fo(i,a,b) for(int i=a;i<=b;i++)#define fd(i,a,b) for(int i=a;i>=b;i--)using namespace std;int n,m,s,tot;int f[105][1<<16],c[105][105],d[105];int main(){ scanf("%d%d",&n,&m); tot=(1<<m)-1; fo(i,1,n) { scanf("%d",&d[i]); fo(j,1,m) { scanf("%d",&c[i][j]); } } memset(f,0x3f,sizeof(f)); f[0][0]=0; fo(i,1,n) { fo(j,0,tot)f[i][j]=f[i-1][j]+d[i]; fo(k,1,m) { fo(j,0,tot) if (~j&((1<<k)-1)) f[i][j|(1<<k-1)]=min(f[i][j|(1<<k-1)],f[i][j]+c[i][k]); } fo(j,0,tot) f[i][j]=min(f[i][j],f[i-1][j]); } printf("%d\n",f[n][tot]);}
0 0
- 【bzoj4145】[AMPPZ2014]The Prices
- 【AMPPZ2014】【BZOJ4145】The Prices
- [BZOJ4145] [AMPPZ2014]The Prices
- bzoj4145 [AMPPZ2014]The Prices
- [bzoj4145][AMPPZ2014]The Prices
- BZOJ4145: [AMPPZ2014]The Prices
- 【bzoj4145】【AMPPZ2014】【The Prices】【状压dp】
- 【BZOJ4145】[AMPPZ2014]The Prices【状压DP】【背包】
- bzoj4145 [AMPPZ2014]The Prices 状压dp
- bzoj4145 [AMPPZ2014]The Prices (状压DP)
- BZOJ 4145: [AMPPZ2014]The Prices
- 【BZOJ4145】【装压DP】 The Prices 题解
- BZOJ 4145 AMPPZ2014 The Prices 状压DP
- 4145: [AMPPZ2014]The Prices 状压DP
- bzoj 4145 [AMPPZ2014]The Prices dp
- bzoj 4145: [AMPPZ2014]The Prices 状压dp
- 【AMPPZ2014】【BZOJ4143】The Lawyer
- 【bzoj4143】[AMPPZ2014]The Lawyer
- JavaScript中一些变态的面试题
- Chrome DevTools 之 Network,网络加载分析利器
- oj2523: 建房工程
- python视频教程大全集下载
- python爬虫requests库详解
- bzoj4145 [AMPPZ2014]The Prices
- Linux 目录结构及说明
- Ubuntu解决 “E: 无法获得锁 /var/lib/dpkg/lock
- 3月题外:关于JS实现图片缩略图效果的一个小问题
- WebGIS开源解决方案之开发环境搭建(四)
- stm32
- 2017-03-09阅读计划
- JSP快速入门教程——全十讲
- Linux 文件系统目录