题目链接

题意

给出正视图和侧视图,判断最少用几个立方体

分析

若存在高度相同的立方块,则以数目多的那面为准。

#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 ;
}
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cstring>
  4. #include <algorithm>
  5. using namespace std;
  6. const int MAXN = 30;
  7. int num1[MAXN],num2[MAXN];
  8. int n,m;
  9. int main(){
  10. while (scanf("%d%d",&m,&n) != EOF && n+m){
  11. memset(num1,0,sizeof(num1));
  12. memset(num2,0,sizeof(num2));
  13. int x;
  14. for (int i = 0; i < m; i++){
  15. scanf("%d",&x);
  16. num1[x]++;
  17. }
  18. for (int i = 0; i < n; i++){
  19. scanf("%d",&x);
  20. num2[x]++;
  21. }
  22. int ans = 0;
  23. for (int i = 1; i < 25; i++)
  24. ans += i*max(num1[i],num2[i]);
  25. printf("%d\n",ans);
  26. }
  27. return 0;
  28. }

UVALive - 4636 Cubist Artwork(贪心)的更多相关文章

  1. UVa LA 4636 Cubist Artwork 难度: 0

    题目 https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_pr ...

  2. UVALive 4225 Prime Bases 贪心

    Prime Bases 题目连接: https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&a ...

  3. UVALive 7464 Robots (贪心)

    Robots 题目链接: http://acm.hust.edu.cn/vjudge/contest/127401#problem/K Description http://7xjob4.com1.z ...

  4. uvalive 3971 - Assemble(二分搜索 + 贪心)

    题目连接:3971 - Assemble 题目大意:有若干个零件, 每个零件给出的信息有种类, 名称, 价格, 质量,  现在给出一个金额, 要求在这个金额范围内, 将每个种类零件都买一个, 并且尽量 ...

  5. UVALive 4867 Maximum Square 贪心

    E - Maximum Square Time Limit:4500MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit ...

  6. UvaLive 4863 Balloons(贪心)

    题意: 给定n个队伍, 然后A房间有a个气球, B房间有b个气球, 然后给出每个队伍所需要的气球数量和到A B房间的距离, 求把气球全部送到每个队伍的最短距离. 分析: 在气球充足的情况下, 那么我们 ...

  7. UVAlive 2326 Moving Tables(贪心 + 区间问题)

    The famous ACM (Advanced Computer Maker) Company has rented a floor of a building whose shape is in ...

  8. uvalive 2322 Wooden Sticks(贪心)

    题目连接:2322 Wooden Sticks 题目大意:给出要求切的n个小木棍 , 每个小木棍有长度和重量,因为当要切的长度和重量分别大于前面一个的长度和重量的时候可以不用调整大木棍直接切割, 否则 ...

  9. UVALive - 4094 WonderTeam (贪心)

    题目大意: 有n支队伍,每两支队伍打两场比赛(主客场各一次),胜得3分,平得1分,输不得分,比赛结束之后会评选出一个梦之队,梦之队满足以下条件:进球总数最多,胜利场数最多,丢求总数最少,三个都不能并列 ...

随机推荐

  1. 数据库历险记(二) | Redis 和 Mecached 到底哪个好?

    文章首发于微信公众号「陈树义」,专注于 Java 技术分享的社区.点击链接扫描二维码,与500位小伙伴一起共同进步.微信公众号二维码 http://p3npq6ecr.bkt.clouddn.com/ ...

  2. NodeJS旅程 : express - nodejs MVC 中的王牌

    express 正如ASP.NET MVC 在作为.net平台下最佳的 Mvc框架的地位一样,express在 node.js 环境也有着相同的重要性.在百度上 "nodejs expres ...

  3. jenkins pipeline 部署

    一.git 版本控制结合jenkins 发布 sh-4.2$ git branch sh-4.2$ git chekout master sh-4.2$ git tag v1.1 sh-4.2$ gi ...

  4. python3 subprocess模块

    当我们在执行python程序的时候想要执行系统shell可以使用subprocess,这时可以新起一个进程来执行系统的shell命令,python3常用的有subprocess.run()和subpr ...

  5. 软件项目第一次sprint评分表

  6. C#使用结构体,输入5个人的学号,姓名,分数,按照成绩高低排列打印出来

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  7. Alpha冲刺——day9

    Alpha冲刺--day9 作业链接 Alpha冲刺随笔集 github地址 团队成员 031602636 许舒玲(队长) 031602237 吴杰婷 031602220 雷博浩 031602634 ...

  8. 基于 Redis 做分布式锁

    基于 REDIS 的 SETNX().EXPIRE() 方法做分布式锁 setnx() setnx 的含义就是 SET if Not Exists,其主要有两个参数 setnx(key, value) ...

  9. 消息队列1:RabbitMQ解析并基于Springboot实战

    RabbitMQ简介 AMQP:Advanced Message Queue,高级消息队列协议.它是应用层协议的一个开放标准,为面向消息的中间件设计,基于此协议的客户端与消息中间件可传递消息,并不受产 ...

  10. MyBatis分步查询的延迟加载

    延迟加载的概念只存在于分步查询时: 延迟加载的本质是为第一步查询返回的Java Bean创建了一个代理对象: 延迟加载的全局设置有两个: lazyLoadingEnabled,作用为设置select语 ...