UVa 11450 Wedding shopping (DP)
来源:互联网 发布:在淘宝上卖油画好卖吗 编辑:程序博客网 时间:2024/05/14 22:51
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=2445
采用滚动数组实现。
此外,这题颇有点模拟的味道。
完整代码:
/*0.035s*/#include<bits/stdc++.h>using namespace std;bool dp[205];vector<int> tmp;///临时数组int main(){int t, m, c, k, cost, i, mx, tmpmx;bool finalok, ok;scanf("%d", &t);while (t--){scanf("%d%d", &m, &c);memset(dp, 0, sizeof(dp));finalok = dp[tmpmx = 0] = true;while (c--){scanf("%d", &k);ok = false;tmp.clear();while (k--){scanf("%d", &cost);if (finalok)for (i = 0; i <= mx && i + cost <= m; ++i)if (dp[i]) ok = true, tmpmx = max(tmpmx, i + cost), tmp.push_back(i + cost);}mx = tmpmx;memset(dp, 0, sizeof(dp));for (i = 0; i < tmp.size(); ++i) dp[tmp[i]] = true;if (finalok) finalok = ok;}if (finalok) printf("%d\n", mx);else puts("no solution");}return 0;}
0 0
- uva 11450 Wedding Shopping (DP)
- UVa 11450 Wedding shopping (DP)
- UVA 11450 Wedding shopping(DP)
- UVa 11450 - Wedding shopping
- Wedding shopping - UVa 11450 背包+滚动数组
- 11450 - Wedding shopping
- Wedding UVA
- UVa 11294 - Wedding
- UVA 11294 Wedding
- uva 11294 - Wedding(TwoSAT)
- UVA 11294 POJ 3648 Wedding
- UVA - 11294 Wedding(2-SAT)
- Uva 11294 Wedding(2-SAT)
- UVA 11294 Wedding(2-sat)
- USACO Shopping Offers, DP
- Shopping Offers (dp)
- usaco shopping 模拟+dp
- UVA 12582 Wedding of Sultan 解题报告
- 退休教师照顾卧床妻子35年
- jQuery Mobile 表单基础
- 互联网的常用协议以及工作端口
- 改变形状的对话框
- 接收端的视频缓冲方法
- UVa 11450 Wedding shopping (DP)
- 读《拒绝平庸》
- JS window对象的top、parent、opener含义
- 周赛1
- 验证字符串是否包含符号
- 使用 Shell 对进程资源进行监控
- No architectures to compile for (ONLY_ACTIVE_ARCH=YES, active arch=armv7s, VALID_ARCHS=armv7 armv6)
- 【OpenCV】森林火灾检测-1
- 关联关系