【bzoj4145】[AMPPZ2014]The Prices
来源:互联网 发布:javascript dom是什么 编辑:程序博客网 时间:2024/05/19 04:05
状压背包
不太好说
很容易写
然而一开始写了个
总之这个就是当前走到了第i个商店,购买状态是s,然后背包转移,
#include <bits/stdc++.h>#define rep(i,a,b) for(int i=a;i<=b;i++)#define per(i,a,b) for(int i=a;i>=b;i--)#define For(i,a,b) for(int i=a;i< b;i++)#define fors(s0,s) for(int s0=s;s0;s0=(s0-1)&s)#define shl(i) (1 << (i))inline int rd() { char c = getchar(); while (!isdigit(c)) c = getchar() ; int x = c - '0'; while (isdigit(c = getchar())) x = x * 10 + c - '0'; return x;}inline void upmin(int&a , int b) { if (a > b) a = b ; }int n , m , d[101] , c[101][16] , all , f[2][65536];void input() { n = rd() , m = rd(); For(i , 0 , n) { d[i] = rd(); For(j , 0 , m) c[i][j] = rd(); } all = shl(m);}void solve() { int now = 0 , pre = 1; memset(f , 0x3f , sizeof f); f[0][0] = 0; For(i , 0 , n) { now ^= 1 , pre ^= 1; For(s , 0 , all) f[now][s] = f[pre][s] + d[i]; For(k , 0 , m) For(s , 0 , all) if (!(s & shl(k))) upmin(f[now][s | shl(k)] , f[now][s] + c[i][k]); For(s , 0 , all) upmin(f[now][s] , f[pre][s]); } printf("%d\n" , f[now][all - 1]);}int main() { input(); solve(); return 0;}
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
- 多人协作
- android Java String API
- FMDB 数据库简单用法
- arean.c
- jQuery入门学习笔记----第一章 jQuery开发入门
- 【bzoj4145】[AMPPZ2014]The Prices
- Javascript跨域和Ajax跨域解决方案
- C#定时器
- 创建标签
- Connect
- backbone.js选型使用分析
- CSDN学院系统停站升级公告
- Repairing
- 镜像地址