POJ 2371 Questions and answers
来源:互联网 发布:网络英语外教一对一 编辑:程序博客网 时间:2024/06/11 05:50
Questions and answers
Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 11144 Accepted: 5922
Description
The database of the Pentagon contains a top-secret information. We don't know what the information is — you know, it's top-secret, — but we know the format of its representation. It is extremely simple. We don't know why, but all the data is coded by the natural numbers from 1 up to 5000. The size of the main base (we'll denote it be N) is rather big — it may contain up to 100 000 those numbers. The database is to process quickly every query. The most often query is: "Which element is i-th by its value?"— with i being a natural number in a range from 1 to N.
Your program is to play a role of a controller of the database. In the other words, it should be able to process quickly queries like this.
Your program is to play a role of a controller of the database. In the other words, it should be able to process quickly queries like this.
Input
The standard input of the problem consists of two parts. At first, a database is written, and then there's a sequence of queries. The format of database is very simple: in the first line there's a number N, in the next N lines there are numbers of the database one in each line in an arbitrary order. A sequence of queries is written simply as well: in the first line of the sequence a number of queries K (1 <= K <= 100) is written, and in the next K lines there are queries one in each line. The query "Which element is i-th by its value?" is coded by the number i. A database is separated from a sequence of queries by the string of three symbols "#".
Output
The output should consist of K lines. In each line there should be an answer to the corresponding query. The answer to the query "i" is an element from the database, which is i-th by its value (in the order from the least up to the greatest element).
Sample Input
571211237121###43325
Sample Output
1211217123
#include<cstdio>#include<iostream>#include<algorithm>#define maxn 100010using namespace std;int num[maxn];int n,m;int main(){ char s[10]; scanf("%d",&n); for(int i=0;i<n;i++){ scanf("%d",&num[i]); } sort(num,num+n); scanf("%s",s); scanf("%d",&m); while(m--){ int d; scanf("%d",&d); printf("%d\n",num[d-1]); } return 0;}
0 0
- poj 2371 Questions and answers
- poj 2371 Questions and answers
- POJ 2371 Questions and answers
- poj 2371 Questions and answers
- Poj 2371--Questions and answers(QSort)
- POJ 一 2371 Questions and answers
- POJ 2371 Questions and answers(水~)
- POJ2371:Questions and answers
- POJ_2371 Questions and answers
- hdu Questions and answers
- BNU Questions and answers
- google questions and answers
- google questions and answers
- URAL 1026. Questions and answers
- gSOAP toolkit questions and answers
- .NET Interview Questions And Answers
- ural 1026 Questions and Answers
- Tibco designer questions and answers
- 常用的Excel编辑步骤和公式使用
- 使用switch case语句来显示月份的对应天数
- ext4文件系统文件定位流程
- Scala类型参数中协变(+)、逆变(-)、类型上界(<:)和类型下界(>:)的使用
- AudioTrack
- POJ 2371 Questions and answers
- 91.View the Exhibit to examine the error that occurred during the database startup. You opened an RM
- 事件传递和响应者链条
- 如何做一个基于ASP.NET MVC 网站(三)
- 使用for循环嵌套实现乘法口诀表
- hive的更新和删除操作脚本
- 负载均衡 Nginx LVS HAProxy
- HDU-3533
- init进程【1】——init启动过程