UVALive - 4636 Cubist Artwork(贪心)
题意
给出正视图和侧视图,判断最少用几个立方体
分析
若存在高度相同的立方块,则以数目多的那面为准。
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int MAXN = ; int num1[MAXN],num2[MAXN];
int n,m; int main(){
while (scanf("%d%d",&m,&n) != EOF && n+m){
memset(num1,,sizeof(num1));
memset(num2,,sizeof(num2));
int x;
for (int i = ; i < m; i++){
scanf("%d",&x);
num1[x]++;
}
for (int i = ; i < n; i++){
scanf("%d",&x);
num2[x]++;
}
int ans = ;
for (int i = ; i < ; i++)
ans += i*max(num1[i],num2[i]);
printf("%d\n",ans);
}
return ;
}
- #include <iostream>
- #include <cstdio>
- #include <cstring>
- #include <algorithm>
- using namespace std;
- const int MAXN = 30;
- int num1[MAXN],num2[MAXN];
- int n,m;
- int main(){
- while (scanf("%d%d",&m,&n) != EOF && n+m){
- memset(num1,0,sizeof(num1));
- memset(num2,0,sizeof(num2));
- int x;
- for (int i = 0; i < m; i++){
- scanf("%d",&x);
- num1[x]++;
- }
- for (int i = 0; i < n; i++){
- scanf("%d",&x);
- num2[x]++;
- }
- int ans = 0;
- for (int i = 1; i < 25; i++)
- ans += i*max(num1[i],num2[i]);
- printf("%d\n",ans);
- }
- return 0;
- }
UVALive - 4636 Cubist Artwork(贪心)的更多相关文章
- UVa LA 4636 Cubist Artwork 难度: 0
题目 https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_pr ...
- UVALive 4225 Prime Bases 贪心
Prime Bases 题目连接: https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&a ...
- UVALive 7464 Robots (贪心)
Robots 题目链接: http://acm.hust.edu.cn/vjudge/contest/127401#problem/K Description http://7xjob4.com1.z ...
- uvalive 3971 - Assemble(二分搜索 + 贪心)
题目连接:3971 - Assemble 题目大意:有若干个零件, 每个零件给出的信息有种类, 名称, 价格, 质量, 现在给出一个金额, 要求在这个金额范围内, 将每个种类零件都买一个, 并且尽量 ...
- UVALive 4867 Maximum Square 贪心
E - Maximum Square Time Limit:4500MS Memory Limit:0KB 64bit IO Format:%lld & %llu Submit ...
- UvaLive 4863 Balloons(贪心)
题意: 给定n个队伍, 然后A房间有a个气球, B房间有b个气球, 然后给出每个队伍所需要的气球数量和到A B房间的距离, 求把气球全部送到每个队伍的最短距离. 分析: 在气球充足的情况下, 那么我们 ...
- UVAlive 2326 Moving Tables(贪心 + 区间问题)
The famous ACM (Advanced Computer Maker) Company has rented a floor of a building whose shape is in ...
- uvalive 2322 Wooden Sticks(贪心)
题目连接:2322 Wooden Sticks 题目大意:给出要求切的n个小木棍 , 每个小木棍有长度和重量,因为当要切的长度和重量分别大于前面一个的长度和重量的时候可以不用调整大木棍直接切割, 否则 ...
- UVALive - 4094 WonderTeam (贪心)
题目大意: 有n支队伍,每两支队伍打两场比赛(主客场各一次),胜得3分,平得1分,输不得分,比赛结束之后会评选出一个梦之队,梦之队满足以下条件:进球总数最多,胜利场数最多,丢求总数最少,三个都不能并列 ...
随机推荐
- Sterling B2B Integrator与SAP交互 - 02 安装配置
系统组成: 1. 服务器OS及硬件: OS: Red Hat Enterprise Linux Server release 6.6 Hardware: Virtual Machine, x86_64 ...
- web项目_学生证管理系统
项目简述: 基于java web实现学生卡管理系统,用户包括学生和学生处,分别实现以下功能. 学生: 1.对本人登录密码的修改 2.申请补办学生卡 3.查看学生卡补办状态 学生处: 1.对学生信息的管 ...
- 【Tableau】电商广告投放的地域分析
分析师的职责是利用处理数据获取信息,提炼规律,帮助企业正确决策业务方向. 所以,一个好的分析师绝不能被数据所困,既要深入业务,理解业务,也要高瞻远瞩,以领导者的思维借助数据分析的辅助做出判断. [结构 ...
- Cloud Native Weekly | KubeCon首登中国,华为云亮相KubeCon 2018,微软云服务又罢工
1.KubeCon首登中国,Kubernetes将如何再演进? 11月14日,由CNCF发起的云原生领域全球最大的峰会之一KubeCon+CloudNativeCon首次登陆中国,中国已经成为云原生领 ...
- django反向解析URL和URL命名空间
django反向解析URL和URL命名空间 首先明确几个概念: 1.在html页面上的内容特别是向用户展示的url地址,比如常见的超链接,图片链接等,最好能动态生成,而不要固定. 2.一个django ...
- 《Linux内核分析》 第六节 进程的描述和进程的创建
<Linux内核分析> 第六节 进程的描述和进程的创建 20135307 张嘉琪 原创作品转载请注明出处 +<Linux内核分析>MOOC课程http://mooc.study ...
- c# dataGridView cell添加下拉框
应用场景: dataGridView需要某一个cell变成下拉框样式. 思路详解: dataGridVie添加固定格式的row. 代码: DataGridViewRow row = new DataG ...
- Navicat连接Mysql8.0失败:Client does not support authentication protocol requested by server...
今天Mysql服务无法启动,看着网上的教程稀里糊涂的就用命令mysqld --initialize给初始化了,结果就是以前的表都没了,重新安装后,Navicat无法连接数据库 解决方法如下: 意思是直 ...
- 关于增强的for循环
增强的for循环例子:public static<AnyType> void print(Collection<AnyType> coll){ for(AnyType item ...
- 第一个sprint与第二个sprint阶段总结
总体: 在第一个sprint中,团队里的小伙伴都在积极努力的配合,基本按照流程做了一次Sprint,大家一块进行计划会议,一块估计任务工时,但是还是有一些意外的事情,这段时间大家都没什么精力放在这门上 ...