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

    asterisk-sounds-core-en_GB-1.5.0-2.fc26.noarch.rpm 2017-02-14 08:24 26K fedora Mirroring Project ast ...

  2. ETL利器Kettle实战应用解析系列二

    本系列文章主要索引如下: 一.ETL利器Kettle实战应用解析系列一[Kettle使用介绍] 二.ETL利器Kettle实战应用解析系列二 [应用场景和实战DEMO下载] 三.ETL利器Kettle ...

  3. Web测试技术要领

    基于Web的系统测试与传统的软件测试既有相同之处,也有不同的地方,对软件测试提出了新的挑战.基于Web的系统测试不但需要检查和验证是否按照设计的要求运行,而且还要评价系统在不同用户的浏览器端的显示是否 ...

  4. 从一个局长使用BS系统的无奈看测试点

    今天我点名买了个B/S系统,听说只要有浏览器就能用.我最讨厌装客户端了,用浏览器就是方便啊. 下面就是我使用这个系统碰到的麻烦事: 我登录失败的时候没有任何提示,这没什么,反正提示也只是说失败…… 进 ...

  5. if(a==1) & if(1==a) 区别

    [前提] 在公司参加项目时,看到前辈写if比较数值是否相等,经常会写 if(1==a) ,觉得有些奇怪,如是乎,将调查结果写下来记录一下. [结果] if(a==1) 与 if(1==a)是没有什么区 ...

  6. matlab随笔

    主要是记录一些函数.(博客园的一些操作实在是太不方便了) cat函数:http://blog.sina.com.cn/s/blog_6b7dfd9d0100mnz7.html 联结两个数组 magic ...

  7. php 的swoole 和websocket 连接wss

    1. 下载证书 $serv = new swoole_server('0.0.0.0', 9501, SWOOLE_PROCESS, SWOOLE_SOCK_TCP | SWOOLE_SSL); $s ...

  8. P1183 多边形的面积

    一道睡论数论题 其实是AC300祭才做的水题 题意: 很直白的的题意啊,就是求任意一个多边形的面积 所以我们来安利一下一个求多边形面积的数学通式: 给定多边形的顶点坐标(有序),让你来求这个多边形的面 ...

  9. 2016-2017-2 20155309南皓芯《java程序设计》第七周学习总结

    教材学习内容总结 Lambda 一种匿名方法 表达式构成 括号以及括号里用逗号分隔的参数列表 仅有一个参数的可以省略括号 ->符号 花括号以及花括号里的语句 仅有一条语句时可以省略花括号,并且这 ...

  10. CSS常见简写规则整理

    外边距(margin) margin-top margin-right margin-bottom margin-left 简写顺序为顺时针方向(上.右.下.左),如:margin: 1px 2px ...