首页 > 代码库 > Poj_2371 Questions and answers

Poj_2371 Questions and answers

题目链接: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[5];    cin >> n;    for ( i = 0; i < n; ++i )        cin >> A[i];    sort( A, A + n );    cin >> Tmp;    cin >> k;    while ( k-- )    {        cin >> j;        cout << a[j-1] << endl;    }    return 0;}

 

Poj_2371 Questions and answers