ZOJ 3211 Dream City(DP)
来源:互联网 发布:苹果5是否支持4g网络 编辑:程序博客网 时间:2024/06/08 12:34
思路:按b值从小到大排序,然后就是简单DP了,因为值越大的肯定放后面转移,所以是可行的
代码:
#include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int N = 255;int t, n, m;struct Tree { int a, b;} tree[N];bool cmp(Tree a, Tree b) { return a.b < b.b;}int dp[N][N];int main() { scanf("%d", &t); while (t--) {scanf("%d%d", &n, &m);for (int i = 1; i <= n; i++) scanf("%d", &tree[i].a);for (int i = 1; i <= n; i++) scanf("%d", &tree[i].b);sort(tree + 1, tree + 1 + n, cmp);for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) {dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - 1] + tree[i].a + tree[i].b * (j - 1)); }}printf("%d\n", dp[n][m]); } return 0;}
0 0
- zoj 3211 Dream City(DP)
- ZOJ 3211 Dream City(DP)
- ZOJ 3211 Dream City(DP)
- ZOJ 3211Dream City(dp)
- ZOJ 3211 Dream City【dp】
- zoj 3211 Dream city dp+贪心
- ZOJ - 3211 Dream City
- zoj 3211 - Dream City
- ZOJ 3211 Dream City
- ZOJ 3211 Dream City
- zoj 3211 Dream City
- ZOJ-3211-Dream City【6th浙江省赛】【dp】
- ZOJ 3211 6th省赛 J Dream City【DP】
- zoj 3211 dream city 贪心 dp和记忆化搜索
- ZOJ-3211-Dream City-DP背包问题+贪心
- zoj 3211 Dream City 动态规划
- zoj 3211 Dream City 贪心+动规
- Dream City ZOJ
- linux ipv6内核设置
- Spring MVC简单介绍
- UVa 11986 - Save from Radiation (推理)
- aabb问题
- 安卓开发之完美解决ADT和SDK不一致问题
- ZOJ 3211 Dream City(DP)
- C# Log4net的使用
- uva1605 - Building for UN 入门经典II 第八章例题8-2
- java.util.concurrent.locks writeread lock 读写锁【3】
- 关于Class.forName(“com.mysql.jdbc.Driver”)
- 免费开源的diff软件“meld”-替代beyond compare的神器
- 查看SDK版本、JDK版本、多个JDK相互切换
- node.js 环境源码安装测试
- ramcloud 5us低时延是如何做到的?