题目链接

题意

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

分析

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

#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. 修炼内功_day01

    测试六段:    测试第一段:        - 能根据测试用例的描述步骤来执行用例        - 能对照用例的预期结果发现产品的问题        - 能够清晰准确的将问题记录下来后反馈给开发, ...

  2. cocos2dx渲染架构

    2dx的时代UI树便利和渲染是没有分开的,遍历UI树的时候就渲染.3dx版本为了分离了ui树的遍历和渲染,先遍历生成渲染命令发到渲染队列,之后遍历渲染命令队列开始渲染.这样做的好处是渲染命令可以重用, ...

  3. gym101522 [小熊骑士限定]La Salle-Pui Ching Programming Challenge 培正喇沙編程挑戰賽 2017

    西瓜队(划掉),Kuma Rider久违的第一场训练,四小时瞎打.jpg A.水题,排序 #include<cstdio> #include<iostream> #includ ...

  4. PAT-1003 Emergency(Dijkstra)

    1003 Emergency (25 分) As an emergency rescue team leader of a city, you are given a special map of y ...

  5. 微软职位内部推荐-Sr. SE - Office incubation

    微软近期Open的职位: Senior Software Engineer-Office Incubation Office China team is looking for experienced ...

  6. BackBone及其实例探究

      摘要 我们小组对MVC框架进行了学习.我的队友们已经在博客中对MVC的设计模式及优缺点进行了详细的探讨与分析,因此我的博客中只对MVC进行简单的介绍,而我将把重心放在Backbone MVC框架一 ...

  7. Notes of Daily Scrum Meeting(12.8)

    今日团队任务总结: 团队成员 今日团队工作 陈少杰 使用例子对json数据进行解析 王迪 确定搜索功能的接口 金鑫 对布局文件进行协助修改 雷元勇 开始进行搜索功能的代码实现 高孟烨 按照学长的样本对 ...

  8. 结巴分词python

    将文件中的txt文档依次读出 并分好词后 写入 另外的TXT中 #coding=utf-8 import os import jieba import codecs import random def ...

  9. 关于Sample的分析报告

    首先,这是一个典型的sample Table box: 一.      Stbl box中常见的子box: stts:Decoding Time to Sample Box时间戳和Sample映射表. ...

  10. beta圆桌 SUM UP

    分工 黄家雄:基础页面 意见反馈 牛康文:基础页面 关于我们 姚志辉:登录注册页面修缮 魏璐炜:多界面修缮,用户使用调查,ppt制作 许斌:自动化测试 傅海涛:文件转换及列表,语音字幕,列表更新 徐明 ...