F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Swimmer

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 1069    Accepted Submission(s): 277


Problem Description
One day, $n$ of swimmers hold a wonderful competition in a swimming pool.

There are $n$ lanes in the swimming pool numbered from $1$ to $n$ , and the their lengths are all $m$ meters. Swimmers are also numbered from $1$ to $n$, and swimmer $i$ occpies lane $i$. The swimmers will start at position $0$, and turn back immediately when arriving at the turn line at position $m$.

They will keep swimming. The speed of swimmers may be different. The speed of the swimmer $i$ is $x_i$ meters per second.

You need to answer $q$ questions: each question gives two integers $p$ and $k$, asking for the position of swimmer $k$ after $p$ seconds.
 

Input
The first line contains three integers $n , m, q$ $(1 \le n \le 10^{6}, 1 \le m \le 10^{9}, 1 \le q \le 10^{6})$, indicating the number of lanes, the length of lanes and the number of questions, respectively.

The second line contains $n$ integers $x_1, x_2, \ldots, x_n$ $(1 \le x_{i} \le 10^{9})$, indicating the speed of each swimmer.

Each of the following $q$ lines contains two integers $p_i, k_i$ $(0 \le p_i \le 10^{9}, 1 \le k_i \le n)$ representing the $i$-th question.
 

Output
Output $q$ lines. Each line contains a single integer, which is the answer of the $i$-th question.
 

Sample Input
1 3 2 1 5 1 7 1
 

Sample Output
1 1
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-05-11 14:07:23, Gzip enabled