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分,输不得分,比赛结束之后会评选出一个梦之队,梦之队满足以下条件:进球总数最多,胜利场数最多,丢求总数最少,三个都不能并列 ...
随机推荐
- REST-framework快速构建API--初体验
一.快速上手 1.环境准备 安装restframework,注册app pip install djangorestframework INSTALLED_APPS = [ 'django.contr ...
- Tkernel Package NCollection哈希基础的类
OpenCASCADE内用到了很多由诸如NCollection_Map, NCollection_DataMap, NCollection_DoubleMap, NCollection_Indexed ...
- 普通程序员看k8s的账户管理
一.知识准备 ● 账户管理分为:userAccount与serviceAccount ● userAccount:通常是给人设计使用的,并且userAccount不在k8s集群内管理 ● servic ...
- PHP学习 函数 function
参数默认值function drink($kind ='tea'){echo 'would you please a cup'.$kind.'<br>';} drink();drink(' ...
- 12.19daily_scrum
本阶段已经过去一半,在周末短暂的休息后,我们将继续完成后续的任务,今日工作情况如下: 小组成员 今日任务 工作时间 李睿琦 网络数据传输应用设计 2 左少辉 主界面功能测试 3 程刚 界面优化学习 4 ...
- kafka学习总结之kafka简介
kafka是一个分布式,基于subscribe-publish的消息系统 特性:高吞吐量.低延迟.可扩展性.持久性(消息持久化到本地磁盘).可靠性.容错性(n个副本,允许n-1个节点失败).高并发(支 ...
- someday团队Postmortem(事后诸葛亮会议)
一.会议相关介绍: 时间:2018年1月12日 地点:第九实验楼五楼机房 参会人员:someday团队全体成员 二.每个成员在beta阶段的实践和alpha阶段有何改进? (一)设想和目标: 我们的软 ...
- Do in SDN
Do in SDN 书籍 <深度解析SDN 利益.战略.战术.实践> 张卫锋 <重构网络-SDN构架与实现>杨泽卫.李呈 <软件定义网络核心原理与应用实践> 黄韬. ...
- We are a team----sh_6666
团队宣言:编程,我们是玩命的,玩命,我们是认真的. 团队简介: 团队名称:sh_6666队 团队博客链接:http://www.cnblogs.com/sh-6666/ 人物简介: 剧团导演:吴小勇 ...
- Beta冲刺——day3
Beta冲刺--day3 作业链接 Beta冲刺随笔集 github地址 团队成员 031602636 许舒玲(队长) 031602237 吴杰婷 031602220 雷博浩 031602134 王龙 ...