Transaction
Practice
3.4 (10 votes)
Approved
Binary search
Data structures
Medium
Merge sort
Open
Segment trees
Problem
44% Success 3050 Attempts 50 Points 1s Time Limit 256MB Memory 1024 KB Max Code
BOB (Bank of Byteland) is the only bank in the land of byteland. Hence million of transactions take place every day. You are currently the manager in charge of BOB. Being bored one day you took all the transaction of that day and asked your friend Codemonk to ask Q queries on the data . Codemonk being a exceptionally good coder gave you two numbers M and N. He then asks you to tell him Nth transaction having cost more than or equal to M maintaining the order of transaction if it exist else print 1. Can you answer all of his queries.
Input
First line of input contains T and Q i.e number of transaction and number of queries,
Next line contains T intergers representing cost of each transaction,
Next Q lines contains two integers representing M and N.
Output
For each query print the cost of required transaction if it exists else print -1.
Constraints
\( 1<=T<=100000\)
\( 1<=Q<=100000\)
\( 1<=Cost\) \(of\) \( each\) \(transaction\) \(<=100000\)
\(1<=M,N<=100000\)
Submissions
Please login to view your submissions
Similar Problems
Points:50
8 votes
Tags:
MediumSegment Trees
Points:50
6 votes
Tags:
Advanced Data StructuresData StructuresMediumQuerySegment Trees普通-難しい
Points:50
Tags:
ApprovedData StructuresMatrixMediumSegment Trees
Editorial