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. Nagios Openstack Plugin

    Some simple example for checking Openstack services check nova service list #!/bin/sh export OS_PROJ ...

  2. tf.summary.merge_all()

    1.自动管理模式 summary_writer = tf.summary.FileWriter('E:/data/tensorflow-master/1.Cnn_Captcha/result/', f ...

  3. 安装mysql-python报错解决办法

    报错: 按照网上的办法,安装mysql-connector-c-6.1.10-winx64.msi和MySQL-python-1.2.3.win-amd64-py2.7 .exe都不行,又源码安装My ...

  4. MySQL学习笔记:insert into select

    从一个表复制数据插入到另外一个表,目标表中任何已存在的行都不会受影响. 语法: INSERT INTO table_xxx VALUES(); INSERT INTO table_xxx SELECT ...

  5. vector 测试

    vector 测试 */--> div.org-src-container { font-size: 85%; font-family: monospace; } pre.src { backg ...

  6. 20165203 第6周《Java程序设计》学习

    教材学习内容总结 第八章 String类 分清常量池和变量池. String类的常用方法 public int length() public boolean eauals(String s) pub ...

  7. Linux学习笔记之一及虚拟机的安装

    学习Linux基础入门 学习实验楼Linux基础入门--学习笔记系列博客 第一节 Linux系统简介 Linux就是一个操作系统,操作系统在计算机系统中包括系统调用和内核两层.在简单了解了Linux的 ...

  8. **PHP转义Json里的特殊字符的函数

    http://www.banghui.org/11332.html 在给一个 App 做 API,从服务器端的 MySQL 取出数据,然后生成 JSON.数据中有个字段叫 content,里面保存了文 ...

  9. Ansible介绍及安装部署

    本节内容: 运维工具 Ansible特性 Ansible架构图和核心组件 安装Ansible 演示使用示例 一.运维工具 作为一个Linux运维人员,需要了解大量的运维工具,并熟知这些工具的差异,能够 ...

  10. Spark介绍及安装部署

    一.Spark介绍 1.1 Apache Spark Apache Spark是一个围绕速度.易用性和复杂分析构建的大数据处理框架(没有数据存储).最初在2009年由加州大学伯克利分校的AMPLab开 ...