UVA - 11991 Easy Problem from Rujia Liu?
来源:互联网 发布:软件定制骗局 编辑:程序博客网 时间:2024/05/22 17:12
Description
Problem E
Easy Problem from Rujia Liu?
Though Rujia Liu usually sets hard problems for contests (for example, regional contests like Xi'an 2006, Beijing 2007 and Wuhan 2009, or UVa OJ contests like Rujia Liu's Presents 1 and 2), he occasionally sets easy problem (for example, 'the Coco-Cola Store' in UVa OJ), to encourage more people to solve his problems :D
Given an array, your task is to find the k-th occurrence (from left to right) of an integer v. To make the problem more difficult (and interesting!), you'll have to answer m such queries.
Input
There are several test cases. The first line of each test case contains two integers n, m(1<=n,m<=100,000), the number of elements in the array, and the number of queries. The next line contains n positive integers not larger than 1,000,000. Each of the following m lines contains two integer k and v (1<=k<=n, 1<=v<=1,000,000). The input is terminated by end-of-file (EOF). The size of input file does not exceed 5MB.
Output
For each query, print the 1-based location of the occurrence. If there is no such element, output 0 instead.
Sample Input
8 41 3 2 2 4 3 2 11 32 43 24 2
Output for the Sample Input
2070
Rujia Liu's Present 3: A Data Structure Contest Celebrating the 100th Anniversary of Tsinghua University
Special Thanks: Yiming Li
Note: Please make sure to test your program with the gift I/O files before submitting!
#include<iostream>#include<cstdio>#include<vector>using namespace std;const int MAXN = 1000000 + 10;vector<int>vec[MAXN];int main(){int n, m;int num,xu;while (scanf("%d", &n) != EOF){scanf("%d", &m);for (int i = 0; i <= MAXN; i++)vec[i].clear();for (int i = 1; i <= n; i++){scanf("%d", &num);vec[num].push_back(i);}for (int j = 1; j <= m; j++){scanf("%d%d", &xu, &num);if (vec[num].size() < xu) cout << 0 << endl;else cout << vec[num][xu-1]<<endl;}}}
- UVA - 11991 Easy Problem from Rujia Liu?
- uva - 11991 - Easy Problem from Rujia Liu?
- uva 11991 Easy Problem from Rujia Liu?
- uva 11991 - Easy Problem from Rujia Liu?
- Uva-11991-Easy Problem from Rujia Liu?
- Uva 11991 - Easy Problem from Rujia Liu?
- UVA 11991 Easy Problem from Rujia Liu?
- UVA 11991 Easy Problem from Rujia Liu?
- uva 11991 Easy Problem from Rujia Liu?
- UVA 11991 Easy Problem from Rujia Liu?
- UVA 11991 Easy Problem from Rujia Liu?
- uva 11991 - Easy Problem from Rujia Liu?
- UVa:11991 Easy Problem from Rujia Liu?
- UVA - 11991 Easy Problem from Rujia Liu?
- UVA 11991 Easy Problem from Rujia Liu?
- UVa 11991 - Easy Problem from Rujia Liu?
- UVA 11991 Easy Problem from Rujia Liu?
- UVa 11991 Easy Problem from Rujia Liu?
- 九度OJ-1101-计算表达式
- PHP 二分查找
- 2015-3-25C语言学习日记
- Android Asynchronous Http Client-Android异步网络请求客户端接口
- Hash Buckets Concept
- UVA - 11991 Easy Problem from Rujia Liu?
- ONF组织的SDN架构文档——概述(一)
- 不是Oculus在主导虚拟现实市场?那是谁?
- 批量插入sheet表,并按顺序命名
- 如何在Gentoo上使用Radeon显卡的开源驱动
- cocos2dx3.0rc导出自定义类到lua的方法详细步骤
- Java基础学习日记Day01
- iOS UITextField 关闭键盘的 三种方法
- java基础知识大全