3031: 【普及-】【P1918】保龄球

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

题目描述

DL 算缘分算得很烦闷,所以常常到体育馆去打保龄球解闷。因为他保龄球已经打了几十年了,所以技术上不成问题,于是他就想玩点新花招。

DL 的视力真的很不错,竟然能够数清楚在他前方十米左右每个位置的瓶子的数量。他突然发现这是一个炫耀自己好视力的借口——他看清远方瓶子的个数后从某个位置发球,这样就能打倒一定数量的瓶子。

  1. lns="http://www.w3.org/1998/Math/MathML">

  2. lns="http://www.w3.org/1998/Math/MathML"> 

  3. lns="http://www.w3.org/1998/Math/MathML">

  4. lns="http://www.w3.org/1998/Math/MathML"> 

如上图,每个 “lns="http://www.w3.org/1998/Math/MathML">” 代表一个瓶子。如果 DL 想要打倒 lns="http://www.w3.org/1998/Math/MathML">3 个瓶子就在 lns="http://www.w3.org/1998/Math/MathML">1 位置发球,想要打倒 lns="http://www.w3.org/1998/Math/MathML">4 个瓶子就在 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"> 个位置的瓶子数,保证各个位置的瓶子数不同。

第三行包含一个正整数 lns="http://www.w3.org/1998/Math/MathML">,表示 DL 发球的次数。

第四行至文件末尾,每行包含一个正整数 lns="http://www.w3.org/1998/Math/MathML">,表示 DL 需要打倒 lns="http://www.w3.org/1998/Math/MathML"> 个瓶子。

输出

共 lns="http://www.w3.org/1998/Math/MathML"> 行。每行包含一个整数,第 lns="http://www.w3.org/1998/Math/MathML"> 行的整数表示 DL 第 lns="http://www.w3.org/1998/Math/MathML"> 次的发球位置。若无解,则输出 lns="http://www.w3.org/1998/Math/MathML">0

样例输入 复制

5
1 2 4 3 5
2
4
7

样例输出 复制

3
0

提示

【数据范围】

对于 lns="http://www.w3.org/1998/Math/MathML">50% 的数据,lns="http://www.w3.org/1998/Math/MathML">1,1000,1,105

对于 lns="http://www.w3.org/1998/Math/MathML">100% 的数据,lns="http://www.w3.org/1998/Math/MathML">1,100000,1,109

#include<bits/stdc++.h>
using namespace std;
map<int,int> m;
int n,q,t;
int main(){
    cin >> n;
    for(int i = 1; i <=n; i++) {
    	cin >> t;
    	m[t] = i;
	}
	cin >> q;
	while(q--) {
		cin >> t;
		cout << m[t] <<endl;
	}
	return 0;
}