BZOJ 4145 AMPPZ2014 The Prices 状压DP
来源:互联网 发布:大数据电信应用教程 编辑:程序博客网 时间:2024/05/17 06:31
题目大意:给定n个商店和m种物品,你需要每种物品买一个,去第
令
然后每个商店内跑个背包即可
时间复杂度
#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>using namespace std;int n,m;int c[110][20],d[110],f[110][1<<16];int main(){ int i,j,k; cin>>n>>m; for(i=1;i<=n;i++) { scanf("%d",&d[i]); for(j=1;j<=m;j++) scanf("%d",&c[i][j]); } memset(f,0x3f,sizeof f); f[0][0]=0; for(i=1;i<=n;i++) { for(j=0;j<1<<m;j++) f[i][j]=f[i-1][j]+d[i]; for(k=1;k<=m;k++) for(j=0;j<1<<m;j++) if(~j&(1<<k-1)) f[i][j|(1<<k-1)]=min(f[i][j|(1<<k-1)],f[i][j]+c[i][k]); for(j=0;j<1<<m;j++) f[i][j]=min(f[i][j],f[i-1][j]); } cout<<f[n][(1<<m)-1]<<endl; return 0;}
0 0
- BZOJ 4145 AMPPZ2014 The Prices 状压DP
- bzoj 4145: [AMPPZ2014]The Prices 状压dp
- bzoj 4145 [AMPPZ2014]The Prices dp
- 4145: [AMPPZ2014]The Prices 状压DP
- BZOJ 4145: [AMPPZ2014]The Prices
- 【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
- 为什么我的app老是不流畅,到底哪里出了问题?
- GUI的学习笔记 version1.0
- C++中正确使用PRId64
- 堆排序
- [LeetCode] Rotate List
- BZOJ 4145 AMPPZ2014 The Prices 状压DP
- 怎么像safari一样滑动的时候隐藏navigationbar?
- AIX下安装GNU make
- 【Java线程】锁机制:synchronized、Lock、Condition
- 我是谁
- oracle故障代码
- iOS 通过constraint 进行autolayout的动画
- Linux下搭建tomcat7和mysql5.6
- 我的书单