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 rang…
#include <cstdio> #include <cstdlib> #include <cstring> #include <vector> #include <queue> #include <algorithm> using namespace std; #define AGE_MAX 200 class People { public: ]; int worth; int age; int idx; People(, )…
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 r…
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 n…
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 n…
排序.随便加点优化就能过. #include<iostream> #include<cstring> #include<cmath> #include<algorithm> #include<cstdio> #include<map> #include<queue> #include<string> #include<stack> #include<vector> using names…
题目:https://pintia.cn/problem-sets/994805342720868352/problems/994805421066272768 题意: 给定n个人的名字,年龄和身价.k次查询,每次询问某一个年龄区间的人的前m个最富有的人. 思路: 我好傻系列. 刚开始撒比排序先按照年龄从小到大排然后存某一年龄的开始下标和个数.然后每次复制出某一区间的人,再按答案要求排序. 好傻.后来想想直接就按照答案的要求排序,对于符合要求的那些人,他们输出的时候的相对顺序就是固定的. 所以我…
题目简单,但解题的思路需要转换一下,按常规思路肯定超时,推荐~ 题意:给出n个人的姓名.年龄和拥有的钱,然后进行k次查询,输出年龄在[amin,amx]内的前m个最富有的人的信息.如果财富值相同就就先输出年龄小的,如果年龄相同就按照名字的字典序排序输出- n范围为10^5,所以显然不能每次查询的时候for一遍所有人,把符合条件的选出来再排序输出,这样肯定会超时. 但是注意到年龄的范围只有200,而且最后查询也跟年龄区间有关,那么有什么办法每次查询我只要取在这个年龄段里的人就好.这样就想到用vec…
题意: 输入两个正整数N和K(N<=1e5,K<=1000),接着输入N行,每行包括一位老板的名字,年龄和财富.K次询问,每次输入三个正整数M,L,R(M<=100,L,R<=200),输出至多M位年龄区间在L,R之间的老板的名字年龄和财富,按照财富降序,年龄升序,姓名字典序输出. AAAAAccepted code: #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; st…
http://pat.zju.edu.cn/contests/pat-a-practise/1055 第二组数据比较大,如果单纯排序直接检索会超时,因为每次都是对所有数据进行遍历. N/200=500,说明同一年龄最多可以有500个人,而M=100比较小,意味着同一年龄100以后的人都不会被搜到. #include<iostream> #include<cstring> #include<cstdio> #include <algorithm> using…