2830 蓬莱山辉夜

 时间限制: 1 s
 空间限制: 32000 KB
 题目等级 : 黄金 Gold
 查看运行结果
 
 
题目描述 Description

在幻想乡中,蓬莱山辉夜是月球公主,居住在永远亭上,二次设定说她成天宅在家里玩电脑,亦称NEET姬
一天,她要她帮忙升级月球的网络服务器,应为注册用户过多(月兔和地球上的巫女都注册了……),所以作为代理管理员(俗称网管)的她,非常蛋疼。
注册用户格式:
TouhouMaiden 2004 200
其中前面的Touhoumaiden是预设,不做更改,第一个数是标识,第二个数是每次接受信息访问的间隔用时。
你要做的事,就是给定一群用户及n,求出这n次信息访问中,访问到了谁?

presented by Izayoi sakuya

输入描述 Input Description

以题目预设格式输入,另起一行以‘#’结束,在其一行输入n

输出描述 Output Description

n行,每行输出第行次后,信息访问到了谁?若在一个时间有若干少女被访问到,输出字典序最小的那位少女的标识

样例输入 Sample Input
TouhouMaiden 2004 200
TouhouMaiden 2005 300
#
5
样例输出 Sample Output
2004
2005
2004
2004
2005
数据范围及提示 Data Size & Hint

标识和每次信息访问间隔均在integer内,n<=10000

原本是要用到堆,但深搜+时间即可搞定

数据有点少但也都够变态了

思路:

  手写堆模拟。。

  恶心简直;

  把所有的用户名和访问间隔记录下来

  然后我们就可以开始模拟了

  先排序

  把所有的人第一顺序是时间间隔的大小

  第二顺序是用户名的字典序

  然后从一个人开始,把他的n次访问都入堆

  然后开始从第2个人的循环遍历

  把每个人的n次访问都入堆

  每入堆一次都伴随着另一个数据的出堆

  堆里个数维持在n个

  然后,当now的时间大于top的时间则出堆

  好吧,思路说的不是很明白,看代码

来,上代码:

#include <cstdio>
#include <iostream>
#include <algorithm> using namespace std; struct node {
int name,now,times;
};
struct node pos[],cur_; class T_heap {
private:
int n;
struct node heap[]; public:
void up(int now)
{
if(now<=) return ;
int next=now>>;
if(heap[now].now!=heap[next].now)
{
if(heap[now].now>heap[next].now)
{
swap(heap[now],heap[next]);
up(next);
}
}
else
{
if(heap[now].name>heap[next].name)
{
swap(heap[now],heap[next]);
up(next);
}
}
} void down(int now)
{
int next=now,lc=now<<,rc=now<<|;
if(lc<=n)
{
if(heap[lc].now!=heap[next].now)
{
if(heap[lc].now>heap[next].now)
{
next=lc;
}
}
else
{
if(heap[lc].name>heap[next].name)
{
next=lc;
}
}
}
if(rc<=n)
{
if(heap[rc].now!=heap[next].now)
{
if(heap[rc].now>heap[next].now)
{
next=rc;
}
}
else
{
if(heap[rc].name>heap[next].name)
{
next=rc;
}
}
}
if(next!=now)
{
swap(heap[next],heap[now]);
down(next);
}
} void qush(struct node cur_)
{
heap[++n]=cur_;
up(n);
} void pop()
{
heap[]=heap[n--];
down();
} struct node top()
{
return heap[];
}
};
class T_heap heap; int num,n; char flag[]; bool cmp(struct node som,struct node som_)
{
if(som.times!=som_.times) return som.times<som_.times;
else return som.name<som_.name;
} int main()
{
cin>>flag;
while(flag[]=='T')
{
cin>>pos[++num].name;
cin>>pos[num].times;
cin>>flag;
}
cin>>n;
sort(pos+,pos+num+,cmp);
for(int j=;j<=n;j++)
{
pos[].now=pos[].times*j;
heap.qush(pos[]);
}
for(int i=;i<=num;i++)
{
for(int j=;j<=n;j++)
{
pos[i].now=pos[i].times*j;
cur_=heap.top();
if(cur_.now!=pos[i].now)
{
if(pos[i].now<cur_.now)
{
heap.pop();
heap.qush(pos[i]);
}
else break;
}
else
{
if(cur_.name>pos[i].name)
{
heap.pop();
heap.qush(pos[i]);
}
else break;
}
}
}
for(int i=n;i>=;i--)
{
pos[i]=heap.top();
heap.pop();
}
for(int i=;i<=n;i++) printf("%d\n",pos[i].name);
return ;
}

AC日记——蓬莱山辉夜 codevs 2830的更多相关文章

  1. AC日记——楼房 codevs 2995

    2995 楼房  时间限制: 1 s  空间限制: 256000 KB  题目等级 : 黄金 Gold 题解  查看运行结果     题目描述 Description 地平线(x轴)上有n个矩(lou ...

  2. AC日记——传话 codevs 1506 (tarjan求环)

    1506 传话  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 白银 Silver 题解       题目描述 Description 一个朋友网络,如果a认识b,那么如果a第 ...

  3. AC日记——绿色通道 codevs 3342

    3342 绿色通道  时间限制: 1 s  空间限制: 256000 KB  题目等级 : 黄金 Gold 题解  查看运行结果     题目描述 Description <思远高考绿色通道&g ...

  4. AC日记——苹果树 codevs 1228

    1228 苹果树  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 钻石 Diamond 题解  查看运行结果     题目描述 Description 在卡卡的房子外面,有一棵 ...

  5. AC日记——刺激 codevs 1958

    时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold     题目描述 Description saffah的一个朋友S酷爱滑雪,并且追求刺激(exitement,由于刺激 ...

  6. AC日记——红与黑 codevs 2806

    2806 红与黑  时间限制: 1 s  空间限制: 64000 KB  题目等级 : 白银 Silver 题解  查看运行结果     题目描述 Description 有一个矩形房间,覆盖正方形瓷 ...

  7. AC日记——热浪 codevs 1557 (最短路模板题)

    1557 热浪  时间限制: 1 s  空间限制: 256000 KB  题目等级 : 钻石 Diamond 题解  查看运行结果     题目描述 Description 德克萨斯纯朴的民眾们这个夏 ...

  8. AC日记——字典 codevs 4189

    4189 字典  时间限制: 1 s  空间限制: 256000 KB  题目等级 : 大师 Master 题解  查看运行结果     题目描述 Description 最经,skyzhong得到了 ...

  9. AC日记——开关灯 codevs 1690

    开关灯 思路: 线段树: bool懒标记维护: 更新区间时是区间总值减去当前值: 来,上代码: #include <cstdio> #include <cstring> #in ...

随机推荐

  1. The .NET of Tomorrow

    Ed Charbeneau(http://developer.telerik.com/featured/the-net-of-tomorrow/) Exciting times lie ahead f ...

  2. Ubuntu 安装 CLI 并运行 ASP.NET Core 1.0

    Ubuntu 下载地址:http://www.ubuntu.org.cn/download/desktop 注:目前 CLI 的安装命令只支持 Ubuntu 14.04,暂不支持 Ubuntu 14. ...

  3. RHEL6.4 + Oracle 11g DG测试环境快速搭建参考

    环境现状: 两台虚拟主机A和B: 1. A机器已安装ASM存储的Oracle 11g 实例      参考:http://www.cnblogs.com/jyzhao/p/4332410.html 2 ...

  4. 开源物联网框架ServerSuperIO(SSIO),项目中实践应用介绍

    一.项目背景 我们是传统行业,但是我们有一颗不传统的心.企业用户遍布国内和国外,面对行业,要建设行业级的(大)数据平台.一提到大数据平台,大家往往想到Hadoop.Spark.Nosql.分布式等等, ...

  5. 高效 Java Web 开发框架 JessMA v3.4.1

    JessMA 是功能完备的高性能 Full-Stack Web 应用开发框架,内置可扩展的 MVC Web 基础架构和 DAO 数据库访问组件(内部已提供了 Hibernate.MyBatis 与 J ...

  6. 基于SAP的中国式数据分析浅谈

    大数据时代,虽然多数企业数据的应用并不能称得上是“大数据”,但也证实了数据应用的重要性和影响力.确实,数据作为企业发展的信息沉淀,已成为企业的重要资产,如何有效利用数据是每个企业必须面临的课题. 这里 ...

  7. Atittit.研发公司的组织架构与部门架构总结

    Atittit.研发公司的组织架构与部门架构总结 1. archi组织架构与 部门规划2 1.1. 最高五大组织机构2 1.2. 宗教事务部2 1.3. 制度与重大会议委员会2 1.4. 纠纷处理部: ...

  8. heartbeat在yum系发行版本的处理资料

    centos 安装包[rpm]和光盘iso文件 http://mirror.centos.org/centos/ 对应如上包的代码 http://vault.centos.org/ git.cento ...

  9. 获得设备的唯一标识符UDID

    在IOS5之后,苹果为避免根据UDID获得用户的信息,而禁止使用uniqueIdentifier获得UDID,但是仍有些应用需要根据UDID区分设备 有一个系统的库IOKit.framework可以获 ...

  10. Unity3D安卓出包报错

    今天又遇到了在安卓出包时,直接报错了两个错误,报错信息分别如下: Installation failed with the following output: pkg: /data/local/tmp ...