http://acm.hdu.edu.cn/showproblem.php?pid=4505

题目大意:

电梯最开始在0层,并且最后必须再回到0层才算一趟任务结束。假设在开始的时候已知电梯内的每个人要去的楼层,电梯每向上运行一层需要6秒钟,向下运行一层需要4秒钟,每开门一次需要5秒(如果有人到达才开门),并且每下一个人需要加1秒。你能计算出完成本趟任务需要的总时间吗?

思路:

水题。。。。。

先不算到达的人,上楼和下楼事件是固定的,10*最高楼数。

然后有n个人的话不管什么时候走出电梯总和还是n。

那么只需要算在哪一楼需要开门即可,也就是算n个人的目的地有几种楼层

#include <cstdio>
#include <map>
#include <algorithm>
using namespace std;
const int MAXN=1024;
int num [MAXN];
int main ()
{
int T ;
scanf("%d" ,&T);
while(T --)
{
int n ;
scanf("%d" ,&n);
for(int i=0; i<n ;i++)
scanf("%d" ,&num[ i]);
sort(num ,num+ n);
int sum =num[n-1]*10;
int cnt=1;
for(int i=1; i<n ;i++)
{
if(num[i]!=num[i-1])
cnt++;
}
printf("%d\n",sum+cnt*5+n);
}
return 0;
}

当然看有多少不一样的也可以用map或者unique

#include <cstdio>
#include <algorithm>
using namespace std;
const int MAXN=1024;
int num [MAXN];
int main ()
{
int T ;
scanf("%d" ,&T);
while(T --)
{
int n ;
scanf("%d" ,&n);
for(int i=0; i<n ;i++)
scanf("%d" ,&num[ i]);
sort(num ,num+ n);
int sum =num[n-1]*10;
int cnt=unique(num,num+n)-num;
printf("%d\n",sum+cnt*5+n);
}
return 0;
}

2013腾讯编程马拉松||HDU 4505 小Q系列故事——电梯里的爱情 水水水的更多相关文章

  1. 小Q系列故事——电梯里的爱情

    小Q系列故事——电梯里的爱情 Time Limit : 300/100ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other) Total ...

  2. hdu4505小Q系列故事——电梯里的爱情

    小Q系列故事——电梯里的爱情 Time Limit: 300/100 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Tota ...

  3. HD4505小Q系列故事——电梯里的爱情

    Problem Description 细心的同事发现,小Q最近喜欢乘电梯上上下下,究其原因,也许只有小Q自己知道:在电梯里经常可以遇到他心中的女神HR. 电梯其实是个很暧昧的地方,只有在电梯里,小Q ...

  4. HDU 4520 小Q系列故事——最佳裁判

    Time Limit : 500/200ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other) Problem Description 过 ...

  5. HDU 4520 小Q系列故事――最佳裁判(STL)

    小Q系列故事——最佳裁判 Problem Description 过去的2012年对小Q来说是很悲催的一年,失恋了12次,每次都要郁闷1个来月. 好在小Q是个体育迷,在最痛苦的时候,他常常用观看各种体 ...

  6. HDU 4500 小Q系列故事——屌丝的逆袭(简单题)

    http://acm.hdu.edu.cn/showproblem.php?pid=4500 AC代码: #include<math.h> #include<stdio.h> ...

  7. HDU 4500 小Q系列故事——屌丝的逆袭

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4500 解题报告:简单题,数据范围不大,直接暴力每个点,然后再比较出得分最大的点的位置和分数. #inc ...

  8. HDU(4528),BFS,2013腾讯编程马拉松初赛第五场(3月25日)

    题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=4528 小明系列故事——捉迷藏 Time Limit: 500/200 MS (Java/O ...

  9. hdu 4506 小明系列故事——师兄帮帮忙【幂取模乱搞】

    链接: http://acm.hdu.edu.cn/showproblem.php?pid=4506 http://acm.hust.edu.cn/vjudge/contest/view.action ...

随机推荐

  1. WPF和WinForm的区别, 数据驱动与事件驱动的优势对比

    Winform中针对界面的元素进行操作, 所有业务都关联在当前窗口的后台, 而在此之前, 无奈你是双击事件的添加方式.还是后台绑定事件的方式, 你都需要给每个元素一个固定规范的名称, 然后进行相关的数 ...

  2. oracle 01578

    http://blog.itpub.net/7728585/viewspace-670597/ http://www.2cto.com/database/201208/149056.html http ...

  3. leetcode笔记:Sort Colors

    一. 题目描写叙述 Given an array with n objects colored red, white or blue, sort them so that objects of the ...

  4. 具体解释window.location

    window.location 对象所包括的属性 hash//从井号 (#) 開始的 URL(锚) host//主机名和当前 URL 的port号 hostname//当前 URL 的主机名 href ...

  5. html ---- a 标签 在新窗口打开的问题

  6. HTML5多维度数据分析

    详情:http://echarts.baidu.com/index.html

  7. Json应用案例

    Json应用案例之FastJson   这几天在网上找关于Json的一些案例,无意当中找到了一个我个人感觉比较好的就是阿里巴巴工程师写的FastJson. package com.jerehedu.f ...

  8. C/C++(结构体)

    结构体(struct) 从某种意义上说,会不会使用struct,如何使用struct是区别一个开发人员是否具备丰富开发经验的试金石. 处理由不同类型成员构成的构造类型,要采用结构体的方式. 定义:关键 ...

  9. VS Code 关于SFTP上传文件到多服务器的配置

    工欲善其事,必先利其器! 刚学前端的时候一直用的DW来编写代码,其功能非常强大,但在Linux下不能用,所以就转VS Code了. 但是刚开始使用VS Code的时候,很多DW上的功能需要自己安装扩展 ...

  10. Input/output subsystem having an integrated advanced programmable interrupt controller for use in a personal computer

    A computer system is described having one or more host processors, a host chipset and an input/outpu ...