题目链接:http://poj.org/problem?id=2371

思路分析:使用计数排序或其他时间复杂度为O( log N )的排序。

代码如下:

#include <iostream>
#include <algorithm> #define MAX_N ( 100000 + 10 )
using namespace std; int A[MAX_N]; int main()
{
int n, k, i, j;
char Tmp[]; cin >> n;
for ( i = ; i < n; ++i )
cin >> A[i]; sort( A, A + n ); cin >> Tmp;
cin >> k;
while ( k-- )
{
cin >> j;
cout << a[j-] << endl;
} return ;
}

Poj 2371 Questions and answers(排序)的更多相关文章

  1. 101+ Manual and Automation Software Testing Interview Questions and Answers

    101+ Manual and Automation Software Testing Interview Questions and Answers http://www.softwaretesti ...

  2. Top 25 Most Frequently Asked Interview Core Java Interview Questions And Answers

    We are sharing 25 java interview questions , these questions are frequently asked by the recruiters. ...

  3. POJ 2367 (裸拓扑排序)

    http://poj.org/problem?id=2367 题意:给你n个数,从第一个数到第n个数,每一行的数字代表排在这个行数的后面的数字,直到0. 这是一个特别裸的拓扑排序的一个题目,拓扑排序我 ...

  4. poj 3687 Labeling Balls(拓扑排序)

    题目:http://poj.org/problem?id=3687题意:n个重量为1~n的球,给定一些编号间的重量比较关系,现在给每个球编号,在符合条件的前提下使得编号小的球重量小.(先保证1号球最轻 ...

  5. [ACM] POJ 3687 Labeling Balls (拓扑排序,反向生成端)

    Labeling Balls Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10161   Accepted: 2810 D ...

  6. poj 2762(强连通分量+拓扑排序)

    题目链接:http://poj.org/problem?id=2762 题意:给出一个有向图,判断任意的两个顶点(u,v)能否从u到达v,或v到达u,即单连通,输出Yes或No. 分析:对于同一个强连 ...

  7. POJ 2585.Window Pains 拓扑排序

    Window Pains Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 1888   Accepted: 944 Descr ...

  8. POJ 3168 Barn Expansion (几何+排序)

    题目链接:id=3168">POJ 3168 Barn Expansion 题意:抽象出来就是给出n个矩形的坐标是(左下角和右上角的坐标,矩形的边都是平行x,y轴),问有几个矩形和其它 ...

  9. POJ 2359 Questions

    Questions Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 1228   Accepted: 449 Descript ...

随机推荐

  1. php install

    ./configure --prefix=/home/allen.mh/local/php --with-gd=/home/allen.mh/local/gd --with-jpeg-dir=/hom ...

  2. mysql查询结果写入文件

    注:转自csdn zuyi532 方法1: shell> mysql -uroot -proot -h localhost xxx库 -e " select * from xxx表 l ...

  3. NetWare

    本地网络连接属性中就有Netware客户端服务项 概括的说,Netware是NOVELL公司推出的网络操作系统,Netware最重要的特征是基于基本模块设计思想的开放式系统结构. Netware是一个 ...

  4. Unity3D Android手机开发环境配置

    Unity3D Android手机开发环境配置 Date:2014-01-01 07:09 1.配置eclipse环境:首先在官网下载安装包:http://developer.android.com/ ...

  5. DjangoORM一对多&多对多操作

    简要说明 通过操作对象的方式操作数据库 详细步骤 models.py的结构是: 如果models.py中外键定义没有写 related_name='student_teacher', 可以直接用 st ...

  6. android-SQLite 和 Content

    SQLite 游标(Cursor)相当于指向底层数据中结果集的指针,而不是提取和返回结果值的副本,是在结果集中对位置(行)进行控制的管理方式. moveToFirst:把游标移动到查询结果的第一行 m ...

  7. libmemcached安装及简单例子

    libmemcached安装及简单例子 1.下载安装libmemcached  $ wget http://launchpad.net/libmemcached/1.0/0.44/+download/ ...

  8. pcre函数具体解释

    PCRE是一个NFA正则引擎,不然不能提供全然与Perl一致的正则语法功能.但它同一时候也实现了DFA,仅仅是满足数学意义上的正则. PCRE提供了19个接口函数,为了简介,使用PCRE内带的測试程序 ...

  9. C# 关于数据类型转换

    1.强制转换; 需要注意的一个是char不能强制转化成int,如果使用强制转化,得到的是原整数的ASCII码值.该方式对于浮点数会做无条件舍去,失去精确度. 2.利用方法: 类型.Parse(stri ...

  10. SQL Server索引进阶:第六级,标签

    原文地址: Stairway to SQL Server Indexes: Level 6,Bookmarks 本文是SQL Server索引进阶系列(Stairway to SQL Server I ...