码迷,mamicode.com
首页 > 其他好文 > 详细

Poj_2371 Questions and answers

时间:2014-10-06 03:23:49      阅读:176      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   io   os   使用   ar   for   

题目链接: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

标签:style   blog   http   color   io   os   使用   ar   for   

原文地址:http://www.cnblogs.com/tallisHe/p/4007890.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!