1055. The World's Richest (25)-PAT

手把手教你学Simulink--基于未来出行解决方案的场景实例:电动飞行汽车(eVTOL)的动力系统建模与仿真 电动垂直起降飞行器零道路拥堵:三维空间飞行绿色低碳:全电驱动,零排放快速响应:城市内15分钟直达低噪音:相比直升机↓20dB📊 预测:2030年全球eVTOL市场规模将超300亿美元,中国、美国、欧洲加速适航认证。本文通过,构建了电动飞行汽车(eVTOL)动力系统高压电池系统建模电力电子(DC-DC、逆变器)实现PMSM电机+螺旋桨推进系统搭建完整飞行任务动态仿真性能KPI评估与优化。 阅读详情

1055. The World's Richest (25)

时间限制
200 ms
内存限制
128000 kB
代码长度限制
16000 B
判题程序
Standard

Forbes magazine publishes every year its list of billionaires based on the annual ranking of the world's wealthiest people. Now you are supposed to simulate this job, but concentrate only on the people in a certain range of ages. That is, given the net worths of N people, you must find the M richest people in a given range of their ages.

Input Specification:

Each input file contains one test case. For each case, the first line contains 2 positive integers: N (<=105) - the total number of people, and K (<=103) - the number of queries. Then N lines follow, each contains the name (string of no more than 8 characters without space), age (integer in (0, 200]), and the net worth (integer in [-106, 106]) of a person. Finally there are K lines of queries, each contains three positive integers: M (<= 100) - the maximum number of outputs, and [Amin, Amax] which are the range of ages. All the numbers in a line are separated by a space.

Output Specification:

For each query, first print in a line "Case #X:" where X is the query number starting from 1. Then output the M richest people with their ages in the range [Amin, Amax]. Each person's information occupies a line, in the format

Name Age Net_Worth
The outputs must be in non-increasing order of the net worths. In case there are equal worths, it must be in non-decreasing order of the ages. If both worths and ages are the same, then the output must be in non-decreasing alphabetical order of the names. It is guaranteed that there is no two persons share all the same of the three pieces of information. In case no one is found, output "None".

Sample Input:
12 4
Zoe_Bill 35 2333
Bob_Volk 24 5888
Anny_Cin 95 999999
Williams 30 -22
Cindy 76 76000
Alice 18 88888
Joe_Mike 32 3222
Michael 5 300000
Rosemary 40 5888
Dobby 24 5888
Billy 24 5888
Nobody 5 0
4 15 45
4 30 35
4 5 95
1 45 50
Sample Output:
Case #1:
Alice 18 88888
Billy 24 5888
Bob_Volk 24 5888
Dobby 24 5888
Case #2:
Joe_Mike 32 3222
Zoe_Bill 35 2333
Williams 30 -22
Case #3:
Anny_Cin 95 999999
Michael 5 300000
Alice 18 88888
Cindy 76 76000
Case #4:
None
推荐指数:※
来源:http://pat.zju.edu.cn/contests/pat-a-practise/1055
这道题目本身的逻辑很清楚,就是具体处理的时候考虑其给出的”each contains three positive integers: M (<= 100) - the maximum number of outputs“,感谢:Linest Blog http://linest.github.io/blog/2013/05/23/1/ 关于这个的提醒(本来case 2一直过不了)。这样其实每个年龄的人,多不会超过100,因为多的也不会输出。PAT的有些题目的测试集也不能掉以轻心。
#include <iostream>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
using namespace std;
#define  N 100001
int n,k;
typedef struct people{
	char strname[10];
    int age;
	int money;
	bool visited;
}people; 
people *peop;
int query[3];
int compare_money(const void *a ,const void *b)
{
	if(((people *)a)->money>((people *)b)->money
	  ||((people *)a)->age<((people *)b)->age&&((people *)a)->money==((people *)b)->money
	  ||((people *)a)->age==((people *)b)->age&&((people *)a)->money==((people *)b)->money
	                                &&strcmp(((people *)a)->strname,((people *)b)->strname)<0)
		return -1;
	else
		return 1;
}
int main()
{
	int i,j;
	scanf("%d%d",&n,&k);
	peop=new people[n];
	for(i=0;i<n;i++){
		scanf("%s%d%d",peop[i].strname,&peop[i].age,&peop[i].money);
	}
	qsort(peop,n,sizeof(people),compare_money);
	int filter_num=0, filter[N],age_count[201]={0};
	for(i=0;i<n;i++){
		if(++age_count[peop[i].age]<101)//thank Linest,this line stolen from his blog
			filter[filter_num++]=i;
	}
	for(i=0;i<k;i++){
		scanf("%d%d%d",&query[0],&query[1],&query[2]);
		printf("Case #%d:\n",i+1);
		int flag=0;
		int print_num=0;
		for(j=0;j<filter_num&&print_num<query[0];j++){
			int tmp=filter[j];
			int age=peop[tmp].age;
			if(age>=query[1]&&age<=query[2]){
				printf("%s %d %d\n",peop[tmp].strname,peop[tmp].age,peop[tmp].money);
				print_num++;
			}
		}
		if(print_num==0)
			printf("None\n");
	}
	return 0;
}



Hadoop在大数据领域的电商数据分析案例 随着电商行业的迅猛发展,每天都会产生海量的数据,如用户浏览记录、购买行为、商品信息等。如何从这些数据中提取有价值的信息,为电商企业的决策提供支持,成为了电商企业面临的重要问题。Hadoop作为一个开源的分布式计算平台,具有高可靠性、高扩展性和高效性等特点,能够很好地处理大数据。本文的目的就是通过实际案例,详细介绍Hadoop在电商数据分析中的应用,范围涵盖了从数据采集、存储到分析的整个流程。本文首先介绍背景信息,让读者了解Hadoop在电商数据分析中的重要性和应用场景。 阅读详情

相关推荐

gRPC之gRPC开发流程与入门案例

gRPC之gRPC开发流程与入门案例

YIYIYI 3759

pat 1055. The World's Richest (25)

1055. The World's Richest (25) 时间限制 400 ms 内存限制 128000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Forbes magazine publishes every year

Yesterday You Said Tomorrow. 645

从零构建XVC协议栈:FPGA+W5300的跨界调试架构实战

本文详细介绍了如何从零构建XVC协议栈,通过FPGA与W5300以太网控制器的创新组合实现跨界调试架构。重点解析了JTAG时序逆向、TCP/IP协议栈集成与XVC协议实现,提供了硬件设计优化和性能加速技术,为嵌入式开发者和FPGA工程师提供实用的远程调试解决方案。

raspberrypi5的博客 247

1055. The World's Richest (25)

总共 N个人,有K中排行; N行 名字 年龄 身价 …… K行 要输出几人 最小年龄 最大年龄 …… 如果有符合条件的输出前几个即以内对应的姓名、年龄、身价 ,顺序身价>=年龄>=姓名 否则None

⊙-→棒棒糖ing .____` 648

Perplexity SPACE沙箱平台:安全AI开发环境实战解析

沙箱技术通过资源隔离和权限控制创建受限执行环境,其核心原理是容器化隔离机制。在AI开发领域,这种技术解决了环境配置复杂性和安全风险等关键问题。SPACE沙箱平台作为AI代码执行环境,提供了标准化的开发沙箱,支持Python生态和主流AI框架。通过实战案例展示,该平台特别适用于情感分析等NLP任务的快速原型验证,帮助开发者在安全隔离的环境中测试AI模型和算法,显著提升开发效率并降低系统风险。

weixin_29029995的博客 274

详细推导波特图增益和相位曲线

文章来源:https://mp.weixin.qq.com/s/UCy9mRRok5Hc9qHq3qde5g 今天这篇文章想把近段时间关于波特图方面学习的内容整理一下。波特图将会是梳理闭环控制这个系列的开始。目前的计划是,以无源器件为基础,然后结合运放,再过渡到开关电源的环路控制方面。如果对这方面感兴趣的朋友,可以持续一起学习起来,目标就是掌握开关电源的闭环控制。 1. 什么是波特图? 波特图最常见的应用是在线性非时变的系统中,用于对传递函数的增益和相位进行分析,从而判断出系统随频率的响应是否稳定。因此,波

ltqdxl的博客 2万+

1055 The World's Richest (25)

Forbes magazine publishes every year its list of billionaires based on the annual ranking of the world's wealthiest people. Now you are supposed to simulate this job, but concentrate only on the peopl...

ysq96的博客 552

论文工具——写论文好用的绘图工具(甘特图+流程图+网络模型图+泳道图)

* 在写HiFi-GAN论文的代码阅读过程中,我发现仅仅通过文字来描述网络结构,不够详细,所以想绘制出网络结构图,更加具象化的描述出网络结构。想去花了,才发现之前都是通过在线绘图网站画的,费时费力,所以想找一些专门的网站化出比较规范并且高质量的图。一方面是为了方便讲解,提高论文的质量,另外一方面也是为了以后写论文打下良好的基础。 * 这篇文章会根据我以前的画图经验展开,以前是使用绘图软件,手动绘图。后来,看到了其他的方法,但是需要写一些代码,或者需要安装特定的软件,投入成本太大,就没有学。所以,本文分享的工

Blackoutdragon的博客 1万+

【PAT】1055. The World's Richest (25)

题目链接:http://pat.zju.edu.cn/contests/pat-a-practise/1055 题目描述: Forbes magazine publishes every year its list of billionaires based on the annual ranking of the world's wealthiest people. Now you

此去经年 1924

SpringCloud Alibaba - Seata 实现高可用和异地容灾

这里不仅仅要实现高可用,还需要实现异地容灾. 异地容灾就是说,如果你整了好几个节点部署起来,全部放到一个机房里面,那么如果这个机房出了故障,就意味着整个集群就完了,所以对于一个大型的集群来讲,都会把这些服务异地部署.问题2:如果我们要实现异地容灾,也就说某一个机房挂了,需要快速的切换到另一个可用的机房,但是这个配置在配置文件中写死了,如果要改配置文件,还需要重启服务器,这是我们不希望看到的,怎么办?进入 seata/bin 目录,运行 seata-server.bat 文件,默认端口为 8091。

CYK_byte的博客 975

【AUTOSAR-E2E】-2.1-配置E2E:基于E2EPW配置一个RX接收的Signal Group(使用E2E Profile 2)

《共13页精讲》:此法也适用于E2E Profile 4/5/6/7/11/22 目录 1 检查CAN Matrix Arxml/DBC是否满足E2E需求 2 在DaVinci Developer中为Port添加E2E保护 3 在DaVinci Configurator settings设置 4 如何使用应用层的E2E保护 5 结尾 <--返回「Autosar_BSW高阶配置」总目录--> <--返回「Autosar_BSW高阶配置」专栏主页--> <--

「汽车电子助手」的博客 4417

PAT甲级 1055 The World's Richest (25分)

1055 The World’s Richest (25分) 题目大意:输入第一行给出两个数n和k,分别代表人的总数和查询总数。随后n行给出一些人的名字,年龄,财富值。最后给出k次查询,每次查询给出一个数m以及年龄最小值和最大值,其中m是最大输出数(最大值100,即满足要求的可能有成千上万人,但是我们只输出100人)。要求我们输出在这个年龄区间内的m人,输出规则是按财富值降序输出,如果财富值相...

weixin_43684054的博客 252

osg中显示3dtiles和cesiumIon

如下图为CesiumTilesetNode数据更新相关代码,将OSG对应的ViewMatrix、ProjectionMatrix和窗口信息传递给tileset->updateView()实现Cesium-native的场景更新。整体结构,其中 CesiumTilesetNode依赖Cesium3DTilesSelection::Tileset,实现数据的更新以及确定需要绘制的节点。1.1 CesiumNative3DTileslayer图层。

CPWWHSU的博客 889

PAT甲级-1055 The World's Richest (25分)

点击链接PAT甲级-AC全解汇总 题目: Forbes magazine publishes every year its list of billionaires based on the annual ranking of the world’s wealthiest people. Now you are supposed to simulate this job, but concentr...

卷子的博客 330

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

PAT 1055. The World's Richest (25)

//1055. The World's Richest (25) //这道题主要方法很简单,但是很容易超时,所以需要适当的剪枝。 //剪枝的方法是: 另外对age开辟一个数组,由于每次只需要输出给定范围内的最多100个结果,所以对相同age的100个以后的数据不做考虑,建立age在整个数组中的索引。 //acc #include #include #include using namespa

xuxumoi 441

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

PAT甲级1055 The World's Richest (25 分)

1055The World's Richest(25分) Forbes magazine publishes every year its list of billionaires based on the annual ranking of the world's wealthiest people. Now you are supposed to simulate this job, ...

Dexter 157

PAT 1055 The World's Richest (25 分)

1055 The World’s Richest (25 分) Forbes magazine publishes every year its list of billionaires based on the annual ranking of the world’s wealthiest people. Now you are supposed to simulate this job, b...

peanWang的博客 146

PAT A1055 The World's Richest (25 分) 排序

题目大意:给出N个人的姓名、年龄和资产信息,要求输出在指定年龄区间内最富有的M个人的信息。 按照资产排序后,直接暴力遍历所有人的信息,符合年龄要求的输出,并维护已经输出的数量<=M即可。不过这样测试点2耗时会比较长,题目似乎更改了时间限制,按照以前的200ms的时间限制需要换一种思路,即一开始就要将每个年龄的前M个人单独存放到数组里,查询的时候从这个数组里查询。不过既然放宽...

HackingGate的博客 166

PAT A1055 The World's Richest (25分)

题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805421066272768 题目描述 Forbes magazine publishes every year its list of billionaires based on the annual ranking of the world’s wealthi...

Rhao的博客 266

1055 The World's Richest (25 分)——PAT A

1055The World's Richest(25分) Forbes magazine publishes every year its list of billionaires based on the annual ranking of the world's wealthiest people. Now you are supposed to simulate this job, ...

weixin_42769575的博客 150

PAT1055:The World's Richest (25)

Forbes magazine publishes every year its list of billionaires based on the annual ranking of the world's wealthiest people. Now you are supposed to simulate this job, but concentrate only on the peopl

zjykshen的博客 213

PAT A1055. The World's Richest (25)

Forbes magazine publishes every year its list of billionaires based on the annual ranking of the world's wealthiest people. Now you are supposed to simulate this job, but concentrate only on the peopl

jolivan的博客 288

PAT甲级1055. The World's Richest (25)

Forbes magazine publishes every year its list of billionaires based on the annual ranking of the world’s wealthiest people. Now you are supposed to simulate this job, but concentrate only on the people

liaotl10的博客 404

1055 The World's Richest (25 分) PAT 甲级 排序题 解决超时问题

1055 The World's Richest (25 分) Forbes magazine publishes every year its list of billionaires based on the annual ranking of the world's wealthiest people. Now you are supposed to simulate this job, ...

小渣渣的博客 595
上一篇: 1056. Mice and Rice (25)-PAT
下一篇: 1054. The Dominant Color (20)-PAT
zoushidexing
博客等级 码龄18年 70粉丝 171原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值