1055 The World's Richest (25 point(s))

告别黑窗口!用VSCode+Native Debug调试C/C++程序,比GDB命令行舒服多了 本文介绍了如何使用VSCode配合Native Debug扩展来调试C/C++程序,替代传统的GDB命令行方式。通过可视化调试环境,开发者可以更高效地管理断点、查看变量和调用栈,大幅提升调试效率。文章详细讲解了环境配置、核心调试功能及高级技巧,帮助开发者快速上手这一现代调试工具。 阅读详情

1055 The World's Richest (25 point(s))

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 (≤10​5​​) - the total number of people, and K (≤10​3​​) - 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 [−10​6​​,10​6​​]) 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 Mrichest 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

简单排序题。题目给出严格的名次判定规则,无需考虑同名词问题。 

#include<iostream>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
struct Person{
	string id;int age;int worths;
	bool operator < (const Person &other) const{
		if(worths!=other.worths) return worths>other.worths;
		if(age!=other.age) return age<other.age;
		return id<other.id;
	} 
};
const int MAX = 1e5+7;
Person P[MAX];
int main(void){
	int N,K;cin>>N>>K;
	for(int i=0;i<N;i++){
		cin>>P[i].id>>P[i].age>>P[i].worths;
	}
	sort(P,P+N);
	int output,Amin,Amax;
	for(int i=1;i<=K;i++){
		cin>>output>>Amin>>Amax;
		cout<<"Case #"<<i<<":"<<endl;
		int cnt = 0;
		for(int i=0;i<N;i++){
			if(cnt>=output) break;
			if(P[i].age>=Amin&&P[i].age<=Amax){
				cout<<P[i].id<<" "<<P[i].age<<" "<<P[i].worths<<endl;
				cnt++;
			}
		}
		if(cnt==0) cout<<"None"<<endl; 
	}
	return 0;
}

 

Ubuntu+Dify实战:如何让大模型知识库完美支持图片召回(附避坑指南) 本文详细介绍了在Ubuntu系统上部署Dify平台,并实现大模型知识库图片召回功能的完整实战方案。通过解析Dify处理图片的底层逻辑,重点讲解了配置Nginx代理服务器将本地图片路径转换为可公开访问URL的核心工程步骤,并提供了文档预处理、环境变量配置以及父子分段策略等高级技巧,帮助开发者构建图文并茂的AI应用,有效提升知识库的丰富性和用户体验。 阅读详情

相关推荐

银河麒麟桌面版V10搭建Qt4.8.6开发环境

银河麒麟桌面版V10搭建Qt4.8.6开发环境

qq_34932364的博客 2401

PAT:A1055 The World's Richest (25 分)

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 ...

Ecloss 435

SAP WMS开发实战:用BAPI_L_TO_CREATE_MULTIPLE搞定LT01转储单(附完整代码)

本文详细解析了SAP WMS开发中如何利用BAPI_L_TO_CREATE_MULTIPLE函数模块批量创建LT01转储单。文章深入剖析了核心参数、常见错误及实战代码框架,重点强调了源/目标存储类型等关键字段的获取方法,为系统集成与自动化流程开发提供了可靠的解决方案。

view3的博客 561

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...

chenyutingdaima的博客 1117

DLPFC.h5ad格式数据简便获取方式+STAGATE论文复现问题

简便获取DLPFC.h5ad格式的数据方式

apple_74057836的博客 2257

LibreNMS实战:5分钟搞定Docker部署与中文配置(附常见问题排查)

本文详细介绍了如何使用Docker在5分钟内快速部署LibreNMS,并完成中文界面优化。从环境准备到容器启动,再到中文语言包安装和系统配置调整,提供了完整的实战指南。同时,文章还包含常见问题排查和性能调优建议,帮助用户高效搭建网络监控系统。

e1f2g的博客 1282

1055 The World's Richest (25 分)

1055 The World’s Richest (25 分) 题目意思: 属性 类型 范围 name string 长度 &amp;amp;amp;lt;= 8 age int (0-200] 排序: net_worth 非递增 net_worth 相等 age 非递减 net_worth, age 都相等 name 非递减 开始代码 — 超时了 /* 属性: ...

Cara 459

【openEuler容器镜像部署指南】

【代码】【List集合排序 】

weixin_43878094的博客 1112

7-1 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 peop...

jiang_1603的博客 410

用Python玩转Iris数据集:从数据加载到可视化分析的完整指南

本文提供了使用Python处理Iris数据集的完整指南,涵盖数据加载、探索性分析、特征工程和可视化呈现等关键步骤。通过Pandas、NumPy、Matplotlib和Seaborn等工具,读者将学习如何从零开始完成一个机器学习项目的数据分析流程,掌握数据科学的核心技能。

j2k3l4的博客 850

CUDA:实现使用cuSolverSP底层API实现Cholesky因式分解(附完整源码)

CUDA:实现使用cuSolverSP底层API实现Cholesky因式分解(附完整源码)

希望我的博客,能帮上你解决学习中工作中所遇到的问题 346

7-17 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...

__surtr的博客 318

PCL 直通滤波器【2026最新版】

PCL直通滤波器函数详解以及用于多字段滤波、强度滤波、获取某一时间范围内的点等高阶用法案例分享。博客长期更新,本文最近一次更新时间为:2026年3月11日。

点云侠的博客 40万+

1055 The World's Richest (25 point(s))

题解 很容易超时,各种优化,最后还出现段错误。心态爆炸的一道题。 #include&lt;iostream&gt; #include&lt;cstdio&gt; #include&lt;vector&gt; #include&lt;algorithm&gt; #include&lt;cstring&gt; using namespace std; const int MAXN = 100...

徐伯莱 338

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

1055 The World's Richest (25 point(s))

Matter: 1.搞懂了cmp的完全排序问题。 2.根据输入的范围考虑问题。M的数值 < 100,这个地方如果不对100个人进行单独操作会超时。出现数据太多的时候就用空间换时间,将数据带出来,单独处理。 Code: #include<iostream> #include<algorithm> #include<string.h> using n...

Bonstoppo 251

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

1055 The World's Richest (25 point(s)) - C语言 PAT 甲级

设计思路: 排序 * 根据财富值递减、年龄递增、名字字典序将所有人排序 * 对于每次查询,遍历并将符合指定年龄区间的人输出

有三只土豆 361

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

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

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...

Seqlist_base的博客 229

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...

韩江雪de 小屋 585

1055 The World‘s Richest (25point(s))

1055 The World’s Richest (25point(s)) 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 ran

佳迪斯的博客 167

1055.The World's Richest (25)

1055.The World’s Richest (25)pat-al-10552017-02-08 一开始思路是这样的:先按年龄排序,然后对每一查询,找到起始和结束的下标,将这一段按题意排序,依次输出,其中有些对于None情况的特殊判断,然后进行一次排序将数组还原。有一个测试点超时。 查了查,发现有些说暴力排序会超时,要换方法,但是查到这个:solution Of 1055. The World’

一剑钦安 372

1055. The World's Richest (25)

//1055. The World's Richest (25) #include #include #include using namespace std; struct people { char name[10]; int age; int worth; }People[100000]; bool cmp(people a, people b) { if(a.wort

上善若水 256

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...

qq_39339575的博客 268

A1055 The World s Richest (25分)【C语言】

A1055 The World s Richest (25分)【C语言】 原题链接 晴神… 题目描述: 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

SASAKI_130的博客 473

1055 The World‘s Richest (25 point(s))测试点1和2的超时问题

测试点一超时是因为你用了cin,cout,搞得程序很慢,所以以后写pat的题目别用cin,cout,用的时候很爽,改的时候就知道错了,还有不要用scanf输入string,string是c++的,要用cin,所以这题如果名字在结构体用了string定义就要改成char name[10]了,bool cmp的时候就不能用return a.name<b.name了,这样的话就是只比较首字母,要用cstring库里面的strcmp判断大小,sort里面的cmp是当bool返回为真的时候 ...

m0_51711089的博客 912

有钱人 - The World's Richest People

3月14日好像都比我大,赶上还有希望。 :) http://www.forbes.com/lists/2006/10/Rank_1.htmlRank Name Citizenship Age Net Worth ($bil) Residence 1 William Gates III United States 50 50.0 United States

秦梦瑶的专栏 664

【PAT刷题甲级】1055.The World‘s Richest

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 in a certain range of

C_greenbird的博客 329
上一篇: 1093 Count PAT's (25 point(s))
下一篇: 1051 Pop Sequence (25 point(s))
coderwait
博客等级 码龄9年 20粉丝 210原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值