2524: 【入门】【P3156】询问学号

内存限制:128 MB 时间限制:1.000 S
评测方式:文本比较 命题人:
提交:25 解决:17

题目描述

有 lns="http://www.w3.org/1998/Math/MathML">(2×106) 名同学陆陆续续进入教室。我们知道每名同学的学号(在 lns="http://www.w3.org/1998/Math/MathML">1 到 lns="http://www.w3.org/1998/Math/MathML">109 之间),按进教室的顺序给出。上课了,老师想知道第 lns="http://www.w3.org/1998/Math/MathML"> 个进入教室的同学的学号是什么(最先进入教室的同学 lns="http://www.w3.org/1998/Math/MathML">=1),询问次数不超过 lns="http://www.w3.org/1998/Math/MathML">105 次。

输入

第一行 lns="http://www.w3.org/1998/Math/MathML">2 个整数 lns="http://www.w3.org/1998/Math/MathML"> 和 lns="http://www.w3.org/1998/Math/MathML">,表示学生个数和询问次数。

第二行 lns="http://www.w3.org/1998/Math/MathML"> 个整数,表示按顺序进入教室的学号。

第三行 lns="http://www.w3.org/1998/Math/MathML"> 个整数,表示询问第几个进入教室的同学。

输出

输出 lns="http://www.w3.org/1998/Math/MathML"> 个整数表示答案,用换行隔开。

样例输入 复制

10 3
1 9 2 60 8 17 11 4 5 14
1 5 9

样例输出 复制

1
8
5

提示

#include<bits/stdc++.h>
using namespace std;

int main(){
    int n,m,tmp;
    vector<int> stu;
    cin>>n>>m;
    for (int i=0;i<n;i++) {
    	cin>>tmp;
    	stu.push_back(tmp);
	}
	
	for (int i=0;i<m;i++) {
		cin>>tmp;
		cout<<stu[tmp-1]<<endl;
	}
    
	return 0;
}