oj mrJudge
Toggle navigation
  • Login
    • Forget Password
      Login
User Image

Hello, Stranger

Guest
  • Analysis Mode
  • Problems
    • All Problems
    • Latest Problems
  • Join Us Now
  • Registration
  • Contact Us
  • Infomation
  • About
    • Terms of Use
    • Technical Specifications
    • Credits

arrayfind Batch , stdin/stdout

Registered Users Only

Please login to utilize this feature.

Do note that this website only supports submissions in C++.

arrayfind.html

Problem Description

Rar the cat hates counting and wants you to help. This time, he has an array of numbers not more than 1000000 length long. He also has Q queries. Each query will consist of a number, x. You are supposed to tell him how many numbers in the array are above and below x.

Input

The first line of input consists of L, the length of the array.

The second line of input consists of L integers, space separated. You may assume they all fit into a 32bit signed integer.

The third line of input consists of Q, the number of queries. Q will be not more than 10000.

The following Q line of input consists of one number each, x. You may assume they all fit into a 32bit signed integer.

Output

For each query, output how many numbers is smaller than it and how many numbers are greater than it (See Below).

Sample Input

10
5 8 7 2 4 3 7 9 1 9
5
7
0
100
3
6

Sample Output

Smaller: 5, Greater: 3
Smaller: 0, Greater: 10
Smaller: 10, Greater: 0
Smaller: 2, Greater: 7
Smaller: 5, Greater: 5

Tags

Divide and Conquer

Subtasks and Limits

Subtask Score #TC Time Memory Scoring
1100101s32MBAverage
2011s32MBAverage

Judge Compile Command

g++-8 ans.cpp -o arrayfind -Wall -Wshadow -static -O2 -lm -m64 -s -w -std=gnu++17 -fmax-errors=512

Accepted Submissions

subIDUserTimeMax Time

Past Submissions

subIDUserTimeScore
mrJudge 09.05.20
Copyright © 2020 mrJudge. All rights reserved.