Skip to content

Instantly share code, notes, and snippets.

@khrlimam
Last active July 1, 2018 10:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save khrlimam/6bee326fd051ff2beb5092367983f112 to your computer and use it in GitHub Desktop.
Save khrlimam/6bee326fd051ff2beb5092367983f112 to your computer and use it in GitHub Desktop.
import bisect
n = int(input(''))
n_scores = input('')
n_scores = map(int, n_scores.split())
m = int(input(''))
m_scores = input('')
m_scores = map(int, m_scores.split())
sort_unduplicate_scores = sorted(set(n_scores))
for alice_score in m_scores:
# get to know in what index/position is alice score if it's
# compared to our sorted unduplicate leaderboard score
index = bisect.bisect(sort_unduplicate_scores, alice_score)
# then we count that position from right since our first score is
# began from right. In order to do that we just need to count
# the difference between position of the most right score and
# our compared alice score, then we need to add it with 1
# since difference only count the length between 2 point
# without including the first start position.
position = len(sort_unduplicate_scores)-index+1
print(position)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment