题目描述:原题链接

You are given three multisets of pairs of colored sticks:

R pairs of red sticks, the first pair has length r1, the second pair has length r2, …, the R-th pair has length rR;
G pairs of green sticks, the first pair has length g1, the second pair has length g2, …, the G-th pair has length gG;
B pairs of blue sticks, the first pair has length b1, the second pair has length b2, …, the B-th pair has length bB;
You are constructing rectangles from these pairs of sticks with the following process:

take a pair of sticks of one color;
take a pair of sticks of another color different from the first one;
add the area of the resulting rectangle to the total area.
Thus, you get such rectangles that their opposite sides are the same color and their adjacent sides are not the same color.

Each pair of sticks can be used at most once, some pairs can be left unused. You are not allowed to split a pair into independent sticks.

What is the maximum area you can achieve?

Input
The first line contains three integers R, G, B (1≤R,G,B≤200) — the number of pairs of red sticks, the number of pairs of green sticks and the number of pairs of blue sticks.

The second line contains R integers r1,r2,…,rR (1≤ri≤2000) — the lengths of sticks in each pair of red sticks.

The third line contains G integers g1,g2,…,gG (1≤gi≤2000) — the lengths of sticks in each pair of green sticks.

The fourth line contains B integers b1,b2,…,bB (1≤bi≤2000) — the lengths of sticks in each pair of blue sticks.

Output
Print the maximum possible total area of the constructed rectangles.

Examples
input
1 1 1
3
5
4
output
20

input
2 1 3
9 5
1
2 8 5
output
99

input
10 1 1
11 7 20 15 19 14 2 4 13 14
8
11
output
372

思路:

先将每颜色的长度从大到小排序,后3重循环暴力枚举出答案。因为n只有200。

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
const int N=230;ll r[N],g[N],b[N];
ll dp[N][N][N];
bool cmp(int x,int y)
{return x>y;
}
int main()
{int R,G,B; scanf("%d %d %d",&R,&G,&B);for(int i=1;i<=R;i++) scanf("%lld",&r[i]);for(int i=1;i<=G;i++) scanf("%lld",&g[i]);for(int i=1;i<=B;i++) scanf("%lld",&b[i]);sort(r+1,r+R+1,cmp);sort(g+1,g+G+1,cmp);sort(b+1,b+B+1,cmp);ll res=0;for(int i=1;i<=R+1;i++){for(int j=1;j<=G+1;j++){for(int k=1;k<=B+1;k++){dp[i][j][k]=max(max(dp[i][j][k],dp[i][j-1][k-1]+g[j-1]*b[k-1]),max(dp[i-1][j-1][k]+r[i-1]*g[j-1],dp[i-1][j][k-1]+r[i-1]*b[k-1]));res=max(res,dp[i][j][k]);}}}printf("%lld\n",res);return 0;
}

Colored Rectangles【简单DP】相关推荐

  1. D. Colored Rectangles[思维dp]

    题意: 3种颜色木棍,每次从两种颜色木棍各选一对组成矩形.求最后所有矩形面积和最大值. #include <cstdio> #include <cstring> #includ ...

  2. Codeforces 41D Pawn 简单dp

    题目链接:点击打开链接 给定n*m 的矩阵 常数k 以下一个n*m的矩阵,每一个位置由 0-9的一个整数表示 问: 从最后一行開始向上走到第一行使得路径上的和 % (k+1) == 0 每一个格子仅仅 ...

  3. hdu2067 简单dp或者记忆化搜索

    题意: 小兔的棋盘 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Sub ...

  4. POJ1088:滑雪(简单dp)

    题目链接:  http://poj.org/problem?id=1088 题目要求: 一个人可以从某个点滑向上下左右相邻四个点之一,当且仅当高度减小.求可以滑落的最长长度. 题目解析: 首先要先排一 ...

  5. 第三讲 数学与简单DP【完结】

    目录 1205. 买不到的数目 [数学结论题] 1211. 蚂蚁感冒 [模拟 / 推理] 1216. 饮料换购 [简单 / 模拟] 2. 01背包问题 [板子题] 1015. 摘花生 [简单DP] 8 ...

  6. hdu 2881(简单dp)

     题意:n*n的矩阵,里面有m个格子是有任务要去完成的,t,x,y表示要在第t秒到达(x,y)的格子完成任务,问你最多可以完成多少 解题思路:简单dp,将时间排个序后就是LIS #include< ...

  7. P1005 矩阵取数游戏(__int128模板/简单dp)

    转跳P1005 题目描述 帅帅经常跟同学玩一个矩阵取数游戏:对于一个给定的 n \times mn×m 的矩阵,矩阵中的每个元素 a_{i,j}a i,j ​ 均为非负整数.游戏规则如下: 每次取数时 ...

  8. 最少拦截系统,简单dp,(学长说这是贪心?!。。。。。。也是醉了)

     description 某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能超过前一发的高度.某天, ...

  9. HDU 1158【简单dp】

    题意:给你一个项目,需要几个月来完成买,同时也给你每个月最少需要的工人数.并且告诉你hiring,firing每个工人的钱数,以及每个月应付每个工人的工资.求项目完成时最小花费. 这是个简单dp,思路 ...

  10. 4.15 每周作业 —— 简单DP

    免费馅饼 Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total Submissi ...

最新文章

  1. J2Cache 中使用 Lettuce 替代 Jedis 管理 Redis 连接
  2. vc6.0上安装qt插件
  3. 一文读懂QEMU虚拟机
  4. 网易智慧企业2020年度见面会4大亮点抢先看!
  5. Vue安装live-server
  6. 扒开系统调用的三层皮(下)
  7. flex 学习篇 ---- 导航类容器
  8. 华为鸿蒙系统小米,继华为鸿蒙之后,又一国产系统在悄悄崛起:小米MIOS全面曝光...
  9. c++ 数组初始化_C++入门篇(二十九),字符数组在内存中存储的情况
  10. 最新的ndkr20编译c_NDKr20使用clang编译ffmpeg
  11. 银行数据仓库体系实践_案例:农发行数据交换共享平台建设实践分享
  12. 【pwn】记一道shellcode侧信道攻击
  13. 计算机mac地址设置路由器,路由器设置:如何查看电脑/手机的MAC地址?
  14. 2021年中国互联网安全行业发展状况及发展趋势展望分析[图]
  15. android10隐藏ssid,SSID隐藏手机如何连接 手机连接隐藏ssid无线网络教程
  16. MySQL查询数据库表记录数
  17. 读书笔记之:《心流 最优体验心理学》 米哈里·契克森米哈赖 第一章、第二章
  18. uni-app 商城 的sku算法(vue)
  19. 系统自带测试软件,Windows7自带软件测试RAID系统
  20. 关于负数在计算机中的表示方法

热门文章

  1. 如何将多个doc文档合并在一起
  2. 华硕预装系统笔记本一键恢复系统
  3. [翻译]现代java开发指南 第二部分
  4. C++中compare函数的使用
  5. C1.Win.C1GanttView.C1GanttView 甘特图使用经验:子任务
  6. Android 新手引导添加View的方法
  7. 今天,在瑞丽开了开眼界!
  8. python 检测文件编码_[常用] 在Python中检测网页编码
  9. android培训感想
  10. 实用软件工程课后答案 (张海潘 吕云翔)