PM2.5

Time Limit: 2000/1000

MS (Java/Others)

Memory Limit: 65536/65536 K (Java/Others)

Problem Description

Nowadays we use content of PM2.5 to discribe the quality of air. The lower content of PM2.5 one city have, the better quality of air it have. So we sort the cities according to the content of PM2.5 in asending order.

Sometimes one city’s rank may raise, however the content of PM2.5 of this city may raise too. It means that the quality of this city is not promoted. So this way of sort is not rational. In order to make it reasonable, we come up with a new way to sort the cityes. We order this cities through the diffrence between twice measurement of content of PM2.5 (first measurement – second measurement) in descending order, if there are ties, order them by the second measurement in asending order , if also tie, order them according to the input order.

Input

Multi test cases (about 100), every case contains an integer n which represents there are n cities to be sorted in the first line.

Cities are numbered through 0 to n−1.

In the next n lines each line contains two integers which represent the first and second measurement of content of PM2.5

The ith line describes the information of city i−1

Please process to the end of file.

[Technical Specification]

all integers are in the range [1,100]

Output

For each case, output the cities’ id in one line according to their order.

Sample Input

2 100 1 1 2 3 100 50 3 4 1 2

Sample Output

0 1 0 2 1

题意

简单来说,每个城市都有两个PM值,排序的时候让你按照两个PM值之差,从大到小排序,然后再按照第二个PM值,从小到大,再按照id从小到大排序

题解

照着题意写cmp,然后调用stl的sort就好~

struct node
{
int x;
int y;
int ss;
int id;
};
bool cmp(node a,node b)
{
if(a.ss==b.ss&&a.y==b.y)
return a.id<b.id;
if(a.ss==b.ss)
return a.y<b.y;
return a.ss>b.ss;
}
node kiss[maxn];
int main()
{
int n;
while(cin>>n)
{
REP(i,n)
{
RD(kiss[i].x);
RD(kiss[i].y);
kiss[i].ss=kiss[i].x-kiss[i].y;
kiss[i].id=i;
}
sort(kiss,kiss+n,cmp);
int flag=1;
REP(i,n)
{
if(flag)
{
cout<<kiss[i].id;
flag=0;
}
else
cout<<" "<<kiss[i].id;
}
cout<<endl;
}
}

hdoj 5182 PM2.5 排序的更多相关文章

  1. hdu 5182 PM2.5

    问题描述 目前,我们用PM2.5的含量来描述空气质量的好坏.一个城市的PM2.5含量越低,它的空气质量就越好.所以我们经常按照PM2.5的含量从小到大对城市排序.一些时候某个城市的排名可能上升,但是他 ...

  2. HDOJ/HDU 2535 Vote(排序、)

    Problem Description 美国大选是按各州的投票结果来确定最终的结果的,如果得到超过一半的州的支持就可以当选,而每个州的投票结果又是由该州选民投票产生的,如果某个州超过一半的选民支持希拉 ...

  3. HDOJ(HDU) 1862 EXCEL排序(类对象的快排)

    Problem Description Excel可以对一组纪录按任意指定列排序.现请你编写程序实现类似功能. Input 测试输入包含若干测试用例.每个测试用例的第1行包含两个整数 N (<= ...

  4. hdu 5182 结构体排序

    BC # 32 : 打 BC 的时候没看全三个关键字,WA 了五发,花了近一小时,问了一下才发现少看一个条件,于是顺利给跪. 题意:给出若干城市的两次空气质量,首先按空气质量差排序,若相等则按第二次排 ...

  5. HDOJ 2001 ASCII码排序

    #include<set> #include<iostream> using namespace std; int main() { char a, b, c; while ( ...

  6. 使用page object模式抓取几个主要城市的pm2.5并从小到大排序后写入txt文档

    #coding=utf-8from time import sleepimport unittestfrom selenium import webdriverfrom selenium.webdri ...

  7. HDOJ 1009. Fat Mouse' Trade 贪心 结构体排序

    FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  8. 用python+selenium获取北上广深成五地PM2.5数据信息并按空气质量排序

    从http://www.pm25.com/shenzhen.html抓取北京,深圳,上海,广州,成都的pm2.5指数,并按照空气质量从优到差排序,保存在txt文档里 代码如下: #coding=utf ...

  9. 双拓扑排序 HDOJ 5098 Smart Software Installer

    题目传送门 /* 双拓扑排序:抄的,以后来补 详细解释:http://blog.csdn.net/u012774187/article/details/40736995 */ #include < ...

随机推荐

  1. socket相关系统调用的调用流程

    最近一直在读内核网络协议栈源码,这里以ipv4/tcp为例对socket相关系统调用的流程做一个简要整理,这些相关系统调用的内部细节虽然各有不同,但其调用流程则基本一致: 调用流程: (1)系统调用 ...

  2. 嵌入式linux/android alsa_aplay alsa_amixer命令行用法

    几天在嵌入式linux上用到alsa command,网上查的资料多不给力,只有动手一点点查,终于可以用了,将这个使用方法告诉大家,以免大家少走弯路. 0.先查看系统支持哪几个alsa cmd: ll ...

  3. Nginx中worker_connections的问题

    查看日志,有一个[warn]: 3660#0: 20000 worker_connections are more than open file resource limit: 1024 !! 原来安 ...

  4. C# 读取指定文件夹下所有文件

    #region 读取文件 //返回指定目录中的文件的名称(绝对路径) string[] files = System.IO.Directory.GetFiles(@"D:\Test" ...

  5. day11作业

    一.选择题 1.B 2.D 3.AB 4.C 二.判断题 1.× 2.√ 三.简答题 1. 多态就是事物存在的多种形态. 提高程序的复用性,提高程序的可扩展性和可维护性. 2. 向上转型是指父类引用指 ...

  6. Git系统学习网址

    https://code.csdn.net/help/CSDN_Code/progit/zh/07-customizing-git/01-chapter7

  7. RESTful API 和 Django REST framework

    100天 cmdb最后一天 #RESTful API - 定义规范 如get就是请求题 - 面向资源编程 把网络任何东西都当作资源 #给一个url,根据方法的不同对资源做不同的操作 #返回结果和状态码 ...

  8. Effective STL 学习笔记 Item 30: 保证目标区间足够大

    Effective STL 学习笔记 Item 30: 保证目标区间足够大 */--> div.org-src-container { font-size: 85%; font-family: ...

  9. SonarQube的安装、配置与使用(windows)

    onarQube是管理代码质量一个开放平台,可以快速的定位代码中潜在的或者明显的错误,下面将会介绍一下这个工具的安装.配置以及使用. 准备工作: 1.jdk(不再介绍) 2.sonarqube:htt ...

  10. Jenkins+Ant+Git+Jmeter实现持续集成

    个人记录: 基本的配置与Jenkins+Ant+SVN+Jmeter实现持续集成的配置一样,主要在Jenkins的配置上的区别会有所不同 安装的插件: enkins安装好之后,需要为其安装gitlab ...