bzoj 4145 [AMPPZ2014]The Prices dp
来源:互联网 发布:上海大陆期货交易软件 编辑:程序博客网 时间:2024/06/05 16:21
设
注意到如果
因此对于一种物品集合只需要有一个商店转移时转移这个集合就行。
复杂度
其实也可以直接背包。。。
#include <bits/stdc++.h>using namespace std;#define N 110#define M (1<<16)+10int n,m;int d[N],c[N][21],pos[M];int g[N][M],f[N][M];int main(){ //freopen("tt.in","r",stdin); scanf("%d%d",&n,&m); for(int i=1;i<=n;i++) { scanf("%d",&d[i]); for(int j=1;j<=m;j++)scanf("%d",&c[i][j]); for(int j=1;j<1<<m;j++) { g[i][j]=d[i]; for(int k=0;k<m;k++) if(j>>k&1)g[i][j]+=c[i][k+1]; if(!pos[j]||g[i][j]<g[pos[j]][j]) pos[j]=i; } } memset(f,0x3f,sizeof(f));f[0][0]=0; for(int i=1;i<=n;i++) { for(int j=0;j<1<<m;j++) f[i][j]=f[i-1][j]; for(int j=1;j<1<<m;j++) if(pos[j]==i) { int t=(1<<m)-1-j; for(int k=t;;k=t&(k-1)) { f[i][j+k]=min(f[i][j+k],f[i-1][k]+g[i][j]); if(!k)break; } } } printf("%d\n",f[n][(1<<m)-1]); return 0;}
0 0
- BZOJ 4145 AMPPZ2014 The Prices 状压DP
- bzoj 4145 [AMPPZ2014]The Prices dp
- bzoj 4145: [AMPPZ2014]The Prices 状压dp
- BZOJ 4145: [AMPPZ2014]The Prices
- 4145: [AMPPZ2014]The Prices 状压DP
- 【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 The Prices题解
- BZOJ 4152: [AMPPZ2014]The Captain
- bzoj 4152: [AMPPZ2014]The Captain
- Angular & ionic项目小白总结一些踩过的坑
- 在jsp任务位置加上今天的日期
- 密集匹配实验数据共享
- centOS防火墙中端口的开启和关闭
- QTreeView 设置水平滚动条
- bzoj 4145 [AMPPZ2014]The Prices dp
- 1039. 到底买不买(20)
- android okhttp get 请求带参数
- OpenSSL命令之算法类大全
- PCB设计技巧分层堆叠在控制EMI辐射中的作用
- 基于springMVC+springSecurity3.x+Mybaits3.x的权限系统,开放源码,支持开源
- Hive ORC file实践与优势
- 单点登录原理与简单实现-非常详尽,好文章
- 错误:can't create 事务 lock on /var/lib/rpm/.rpm