您的位置:首页 > 其它

UVa 11991 Easy Problem from Rujia Liu? (用map离散化)

2014-03-04 12:27 405 查看
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=497&page=show_problem&problem=3142

/*0.099s*/

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

map<int, vector<int> > a; /// 离散化,比用vector好

int main()
{
	int n, m, x, y;
	while (~scanf("%d%d", &n, &m))
	{
		a.clear();
		for (int i = 0; i < n; i++)
		{
			scanf("%d", &x);
			if (!a.count(x)) a[x] = vector<int>();
			a[x].push_back(i + 1);
		}
		while (m--)
		{
			scanf("%d%d", &x, &y);
			if (!a.count(y) || a[y].size() < x) printf("0\n");
			else printf("%d\n", a[y][x - 1]);
		}
	}
	return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: