Bugs
Practice
3.2 (11 votes)
Algorithms
Binary search
Fenwick tree
Hard
Hiring
Searching
Problem
92% Success 6114 Attempts 50 Points 2s Time Limit 256MB Memory 1024 KB Max Code

You are developer at XYZ company. You like to call the bugs in your code as enemies. You maintain an array A of the list of enemies in decreasing order of their difficulty i.e., the most difficult bug will be the first element of the array. Initally, there is no bugs in the code. You are given N tasks. Each task contains one of the following two types of operations:

1. 1 P: Add a bug with difficulty P into the array A.

2. 2: Sort the array in decreasing order and print the difficulty of (n / 3)th bug in the sorted array, where n is the size of the array A. If the number of bugs is less than 3, print Not enough enemies.

 

Input Format

First line contains an integer N, denoting the number of tasks.

The next N lines contain one of the two types of operations mentioned above.

 

Output Format

For every operation of type 2, print the difficulty of (n / 3)th bug in the sorted array, where n is the size of the array A. If the number of bugs is less than 3, print Not enough enemies.

 

Constraints:

\(1\le N \le 5 * 10^5 \)

\(1\le P \le 10^9 \)

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:50
6 votes
Tags:
Binary SearchAlgorithmsGreedy Algorithms
Points:30
246 votes
Tags:
ReadyMathematicsSortingApprovedEasy-Medium
Points:50
4 votes
Tags:
AlgorithmsBinary Search