UVA 11991 Easy Problem from Rujia Liu?

用map 和vector很巧妙的解决了


#include<iostream>
#include<cstdio>
#include<map>
#include<vector>
using namespace std;
map <int, vector<int> > a;
int main()
{	
	int n,m;
	while(scanf("%d%d",&n,&m)!=EOF)
	{
		a.clear();
		int temp,k,v;
		for(int i=0;i<n;i++)
		{
				scanf("%d",&temp);
				a[temp].push_back(i+1);
		}
		while(m--)
		{
			scanf("%d%d",&k,&v);
			if(a[v].size()<k) printf("0\n");
			else printf("%d\n",a[v][k-1]);
		}
	}
}


posted @ 2013-08-02 10:06  hr_whisper  阅读(144)  评论(0编辑  收藏  举报