Problem:


Score : 200 points

Problem Statement

You have decided to write a book introducing good restaurants.
There are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i.
No two restaurants have the same score.

You want to introduce the restaurants in the following order:

The restaurants are arranged in lexicographical order of the names of their cities.

If there are multiple restaurants in the same city, they are arranged in descending order of score.

Print the identification numbers of the restaurants in the order they are introduced in the book.

Constraints

1 ≤ N ≤ 100

S is a string of length between 1 and 10 (inclusive) consisting of lowercase English letters.

0 ≤ P_i ≤ 100

P_i is an integer.

P_i ≠ P_j (1 ≤ i < j ≤ N)

Input

Input is given from Standard Input in the following format:

N
S_1 P_1
:
S_N P_N

Output

Print N lines. The i-th line (1 ≤ i ≤ N) should contain the identification number of the restaurant that is introduced i-th in the book.

Sample Input 1

6
khabarovsk 20
moscow 10
kazan 50
kazan 35
moscow 60
khabarovsk 40

Sample Output 1

3
4
6
1
5
2

The lexicographical order of the names of the three cities is kazan < khabarovsk < moscow. For each of these cities, the restaurants in it are introduced in descending order of score. Thus, the restaurants are introduced in the order 3,4,6,1,5,2.

Sample Input 2

10
yakutsk 10
yakutsk 20
yakutsk 30
yakutsk 40
yakutsk 50
yakutsk 60
yakutsk 70
yakutsk 80
yakutsk 90
yakutsk 100

Sample Output 2

10
9
8
7
6
5
4
3
2
1



Sample input:
6
khabarovsk 20
moscow 10
kazan 50
kazan 35
moscow 60
khabarovsk 40


Sample output:
3
4
6
1
5
2

Submission status: Accepted

Solution code:
n = int(input())
q = [input().split() + [i] for i in range(n)]
for i in range(n):
    q[i][1] = int(q[i][1])
p = sorted(sorted(q, key = lambda x:x[1], reverse = True), key = lambda x:x[0])
for s, t, r in p:
    print(r + 1)

Submission status: Accepted

Solution code:
N = int(input())
SP = []
for i in range(N):
    s,p = input().split()
    SP.append((s,int(p),i))
SP.sort(key=lambda x:-x[1])
SP.sort(key=lambda x:x[0])
for i in range(N):
    print(SP[i][2]+1)

Submission status: Accepted

Solution code:
from operator import itemgetter
N = int(input())
L = []
for i in range(N):
    a,b = input().split()
    L.append([i,a,int(b)])
L = sorted(L, key=itemgetter(2), reverse=True)
L = sorted(L, key=itemgetter(1))
for j in range(N):
    print(L[j][0]+1)

Submission status: Accepted

Solution code:
n = int(input())
data =[]
for i in range(n):
  sity, score = input().split()
  data.append([sity, int(score),i+1])
  
data.sort(key=lambda x:(x[0], -x[1]))
for j in range(n):
  print(data[j][2])

Submission status: Accepted

Solution code:
print(*sorted(range(1,int(input())+1),key=lambda _:[(s,-int(p))for s,p in[input().split()]]))

Submission status: Accepted

Solution code:
for*_,i in sorted((t.split()[0],-int(t.split()[-1]),i)for i,t in enumerate(open(0)))[1:]:print(i)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from operator import itemgetter

N = int(input())

SP = []
for n in range(1, N+1):
    [S, P] = [i for i in input().split()]
    SP.append((n, S, int(P)))

sorted_SP = sorted(SP, key=itemgetter(2), reverse=True)
sorted_SP = sorted(sorted_SP, key=itemgetter(1))

for n in range(N):
    print(sorted_SP[n][0])

Submission status: Accepted

Solution code:
for*_,i in sorted((s,-int(p),i)for i in range(int(input()))for s,p in[input().split()]):print(i+1)

Submission status: Accepted

Solution code:
for i in sorted(range(int(input())),key=lambda _:[(s,-int(p))for s,p in[input().split()]]):print(i+1)

Submission status: Accepted

Solution code:
for*_,a in sorted([input().split()+[i]for i in range(int(input()))],key=lambda x:(x[0],-int(x[1]))):print(a+1)

Submission status: Accepted

Solution code:
print('\n'.join([str(s[2])for s in sorted([input().split()+[i+1]for i in range(int(input()))],key=lambda x:(x[0],-int(x[1])))]))

Submission status: Accepted

Solution code:
print(*[s[2]for s in sorted([input().split()+[i+1]for i in range(int(input()))],key=lambda x:(x[0],-int(x[1])))],sep='\n')

Submission status: Accepted

Solution code:
print(*[s[2]for s in sorted([input().split()+[i+1]for i in range(int(input()))],key=lambda x:(x[0],-int(x[1])))], sep='\n')

Submission status: Accepted

Solution code:
n=int(input())
A=[[0 for col in range(3)]for row in range(n)]
#S=[list(input().split())for i in range(n)]
for i in range(n):
  s,p=input().split()
  A[i][0],A[i][1],A[i][2]=s,p,i+1
#A.sort(key=lambda x:x[1])
A.sort(key=lambda x:(x[0],-int(x[1])))
for i in range(n):
  print(A[i][2])

Submission status: Accepted

Solution code:
print(*[s[2] for s in sorted([input().split() + [i + 1] for i in range(int(input()))],key=lambda x:(x[0], -int(x[1])))],sep='\n')

Submission status: Accepted

Solution code:
import pprint

N = int(input())
lst = []
for _ in range(N):
  hoge = list(input().split())
  hoge2 = _
  hoge3 = [hoge,hoge2]
  lst.append(hoge3)

lst.sort(key=lambda x:(x[0][0],-int(x[0][1])))

for i in range(N):
  print(lst[i][1]+1)

Submission status: Accepted

Solution code:
n=int(input())
List=[[input().split() , i+1] for i in range(n)]

List=sorted(List,key=lambda x : (x[0][0],-int(x[0][1])))

for i in range(n):
    print(List[i][1])

Submission status: Accepted

Solution code:
db = {}
n = int(input())
for i in range(n):
  si, pi = input().split()
  if not si in db:
    db[si] = []
  db[si].append({"order": i, "score": int(pi)})

sorted_keys = sorted(db.keys(), key=lambda x: x)
for key in sorted_keys:
  #print("key={}".format(key))
  sorted_by_score = sorted(db[key], key=lambda x: x["score"], reverse=True)
  for ans in sorted_by_score:
    print("{}".format(ans["order"] + 1))

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    restaurants = []
    for i in range(N):
        si, pi = input().split()
        restaurants.append([i+1, si, int(pi)])
    cities = sorted(set([restaurant[1] for restaurant in restaurants]))

    for city in cities:
        same_cities = []
        for restaurant in restaurants:
            if restaurant[1] == city:
                same_cities.append(restaurant)
        sorted_restaurants = sorted(same_cities, key=lambda restaurant: restaurant[2], reverse=True)
        [print(restaurant[0]) for restaurant in sorted_restaurants]


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
ans = []

for i in range(1, N+1):
    S, P = input().split()
    ans.append((S, P, i))

ans = sorted(ans, key=lambda x: (x[0], -int(x[1])))

for i in range(N):
    print(ans[i][2])

Submission status: Accepted

Solution code:
n = int(input())
book = []
for i in range(1, n+1):
        s, p = map(str, input().split())
        book.append([s, int(p), i])
bookSorted = sorted(book, key = lambda x:(x[0],-x[1]))
for i in bookSorted:
        print(i[2])

Submission status: Accepted

Solution code:
print('\n'.join([l[2] for l in sorted(sorted([[l[0], -int(l[1]), str(l[2] + 1)] for l in (input().split() + [i] for i in range(int(input())))], key=lambda x: x[1]), key=lambda x: x[0])]))

Submission status: Accepted

Solution code:
print('\n'.join([l[2] for l in sorted(sorted([[l[0], -int(l[1]), str(l[2] + 1)] for l in [input().split() + [i] for i in range(int(input()))]], key=lambda x: x[1]), key=lambda x: x[0])]))

Submission status: Accepted

Solution code:
from operator import itemgetter

N = int(input())
city_point_list = []
for i in range(N):
    c, p = input().split()
    pair = (c, int(p))
    city_point_list.append(pair)

cp_num_dict = {}
for i in range(len(city_point_list)):
    cp_num_dict[city_point_list[i]] = i + 1

point_sort_rev = sorted(city_point_list, key=itemgetter(1), reverse=True)
city_sort = sorted(point_sort_rev, key=itemgetter(0))

for cp in city_sort:
    print (cp_num_dict[cp])

Submission status: Accepted

Solution code:
n = int(input())
a = []
for i in range(n):
    s, p = input().split()
    a.append((s, -int(p), i))
a.sort()

for _, _, i in a:
    print(i + 1)

Submission status: Accepted

Solution code:
num = int(input())
guide = [[i for i in input().split()] for j in range(0, num)]
dic = 1
for i in range(0, len(guide)):
    guide[i][1] = int(guide[i][1])
    guide[i].append(dic)
    dic += 1
guide.sort(reverse=True, key=lambda x: x[1])
guide_book = sorted(guide, key=lambda x: x[0])

for i in range(0, len(guide)):
    print(guide_book[i][2])

Submission status: Accepted

Solution code:
N = int(input())
SP = [[_ for _ in input().split()] + [_ + 1] for _ in range(N)]
SP.sort(key = lambda x:(x[0],-int(x[1])))
ans = [0] * N

for i, sp in enumerate(SP):
    s, p, x = sp
    ans[i] = x

for j in ans:
    print(j)

Submission status: Accepted

Solution code:
N = int(input())
lst = []

for i in range(N):
    toshi, ten = map(str, input().split())
    lst.append((toshi,int(ten),i+1))

for i in range(N):
    flag = 0
    for j in range(N-1):
        if lst[j][0] > lst[j+1][0]:
            lst[j] ,lst[j+1] = lst[j+1],lst[j]
            flag = 1
    if flag == 0:break

for i in range(N):
    flag = 0
    for j in range(N-1):
        if lst[j][0] == lst[j+1][0]:
            if lst[j][1] < lst[j+1][1]:
                lst[j] ,lst[j+1] = lst[j+1],lst[j]
                flag = 1
    if flag == 0:break
for lst in lst:
    print(lst[2])

Submission status: Accepted

Solution code:
n = int(input())

s_list = []
p_list = []

for _ in range(0, n):
    s, p = input().split()
    s_list.append(s)
    p_list.append(int(p))

result = list(enumerate(zip(s_list, p_list)))
result = sorted(result, key = lambda x: (x[1][0], -x[1][1]))

for i in [ x[0] + 1 for x in result ]:
    print(i)

Submission status: Accepted

Solution code:
n = int(input())
R = []
for i in range(n):
    a = input().split()
    R.append([a[0], -int(a[1]), i+1])

R.sort()
for i in range(len(R)):
    print(R[i][2])

Submission status: Accepted

Solution code:
def solve(n, s, p):
    ids = list(range(1,n+1))
    for _, _, id in sorted(zip(s, p, ids), key=lambda _: "%s-%03d" % (_[0], 100-_[1])):
        print(id)

n = int(input())
s, p = [], []
for i in range(n):
    _s, _p = input().split()
    s.append(_s)
    p.append(int(_p))
solve(n, s, p)

Submission status: Accepted

Solution code:
n=int(input())
sp=[[i for i in input().split()] for j in range(n)]
for k in range(n):
  sp[k][1]=int(sp[k][1])
sp2=sorted(sorted(sp, key=lambda x: x[1])[::-1], key=lambda x:x[0])
for l in sp2:
  print(sp.index(l)+1)

Submission status: Accepted

Solution code:
from sys import stdin, stdout

n = int(stdin.readline().rstrip())

l = list()

for i in range(n):
    s, p = [x for x in stdin.readline().rstrip().split()]
    l.append((s, int(p)*(-1), i + 1))
    
l.sort()
    
for i in range(n):
    print(l[i][2])

Submission status: Accepted

Solution code:
N = int(input())

C = {}
for i in range(N):
  city, score = input().split(' ')
  score = int(score)
  if city not in C:
    C[city] = []
  C[city].append({'score':score,'idx':i})
  
for p in sorted(C.keys()):
  for k in sorted(C[p],key=lambda x:x['score'],reverse=True):
    print(k['idx']+1)

Submission status: Accepted

Solution code:
N = int(input())
SP = [ [i for i in input().split() ] for _ in range(N)]




SP2 = [ [0, 0, 0] for _ in range(N) ]
for _ in range(N):
	SP2[_][0] = SP[_][0]
	SP2[_][1] = -( int(SP[_][1]) )
	SP2[_][2] = _+1

SP2.sort()

for i in range(N):
	print(SP2[i][2])

Submission status: Accepted

Solution code:
#!/usr/bin/env python

import sys
from operator import itemgetter

n = int( sys.stdin.readline().strip() )
rest= []
for i in range(n):
    k,v = sys.stdin.readline().strip().split()
    rest.append( [i+1,k,int(v)] )
#
for x in sorted( rest,key=lambda x: (x[1],-x[2]) ):
    print( x[0] )

Submission status: Accepted

Solution code:
n = int(input())
src = []

for i in range(n):
    s, p = input().split()
    src.append((s, -int(p), i + 1))

src.sort()
for item in src:
    print(item[2])

Submission status: Accepted

Solution code:
n = int(input())
li_w = list()

for _ in range(n):
    li_w.append(input().split())

li_sorted = sorted(li_w, key=lambda x: (x[0], 100 - int(x[1])))
for a in li_sorted:
    print(li_w.index(a) + 1)

Submission status: Accepted

Solution code:
n = int(input())
res = {}
for i in range(0, n):
  s, p = [elem for elem in input().split()]
  if not s in res:
    res[s] = [(int(p), i + 1)]
  else:
    res[s].append((int(p), i + 1))

for key in sorted(res.keys()):
  for score, idx in sorted(res[key], reverse=-1):
    print(idx)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    SP = [list(input().split()) for i in range(N)]
    for i, SPl in enumerate(SP):
        SPl.append(i+1)
        SPl[1] = int(SPl[1])
    # print(SP)
    SP.sort(reverse=True, key=lambda x: x[1])
    # print(SP)
    SP.sort(key=lambda x: x[0])
    # print(SP)

    for sp in SP:
        print(sp[2])


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
rest = {}
cities = []
for i in range(N):
    k,s = input().split()
    if k not in rest:
        rest[k] = []
        cities.append(k)
    rest[k].append([int(s),i+1])
cities.sort()
for k in cities:
    rest[k].sort(reverse = True)
    for i in rest[k]:
        print(i[1])

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
# coding: utf-8
# Your code here!
from operator import itemgetter

N = int(input())
l = []
for i in range(N):
    r = input().split()
    r.append(i + 1)      #並び替え前の番号をIDとして記録しておく
    l.append(r)

l.sort(key=lambda x:(x[0],-int(x[1])))

for i in range(N):
    print(l[i][2])

Submission status: Accepted

Solution code:
# -*- coding utf-8 -*-

N = int(input())

rest = {}
cities = []
for i in range(N):
    k, s = input().split()
    if k not in rest:
        rest[k] = []
        cities.append(k)
    rest[k].append([int(s), i + 1])

cities.sort()
for k in cities:
    rest[k].sort(reverse=True)
    for r in rest[k]:
        print(r[1])

Submission status: Accepted

Solution code:
from operator import itemgetter

if __name__ == '__main__':
    n = int(input())
    input_list = [input() for i in range(n)]
    restaurant_list = []
    for index, _input in enumerate(input_list):
        _restaurant_data = {'id': index + 1, 'region': _input.split()[0], 'point': int(_input.split()[1])}
        restaurant_list.append(_restaurant_data)

    restaurant_list.sort(key=itemgetter('point'), reverse=True)
    restaurant_list.sort(key=itemgetter('region'))
    for restaurant in restaurant_list:
        print(restaurant['id'])

Submission status: Accepted

Solution code:

N = int(input())
H = []
L = []
for i in range(N):
  S, P = input().split()
  P = -int(P)
  H = [S,P,i]
  L.append(H)
L.sort()



for i in range(N):
    print(L[i][2]+1)

Submission status: Accepted

Solution code:
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]

    rs = []
    for i in range(n):
        ss = input().split()
        rs.append((ss[0], int(ss[1]), i+1))
    
    
    rs = sorted(rs, key = lambda x:(x[0],-x[1]))
    for i in rs:
        print(i[2])



solve()

Submission status: Accepted

Solution code:
N = input()
book = []
for i in range(int(N)):
    book.append(list(input().split()))
    book[i][1]=int(book[i][1])
    book[i][1] *= -1
    book[i].append(i+1)
book.sort()
for i in range(int(N)):
    book[i][1] *= -1
    print(book[i][2])

Submission status: Accepted

Solution code:
n = int(input())
dic = {}
area = []
price = {}
trans = {}
modified_price = []
for i in range(n):
    [a,b] = [i for i in input().split()]
    if a not in area:
        area.append(a)
        dic[a] = [int(b)]
    else:
        dic[a].append(int(b))
    price[int(b)] = i+1
area.sort()
#print(area)
for i in range(len(area)):
    for j in range(len(dic[area[i]])):
        trans[dic[area[i]][j]+(len(area)-i)*1000] = dic[area[i]][j]
        modified_price.append(dic[area[i]][j] + (len(area)-i) * 1000)
modified_price.sort(reverse = True)
for i in range(len(modified_price)):
    print(price[trans[modified_price[i]]])

Submission status: Accepted

Solution code:
N = int(input())

result = {}
for i in range(N):
  S, P = input().split()
  P = int(P)
  if S in result:
    result[S].append([P, i])
  else:
    result[S] = [[P, i]] 

score_sorted = sorted(result.items(), key=lambda x:x[0])

for kv in score_sorted:
  v = kv[1]
  s = sorted(v, key = lambda x: x[0], reverse=True)
  for i in s:
    print(i[1] + 1)

Submission status: Accepted

Solution code:
import numpy as np
N = int(input())
restaurants_list = []
for i in range(N):
  name,score = map(str,input().split())
  score = int(score)
  restaurants_list.append([name,score,i+1])
restaurants_list.sort(key = lambda x:x[1],reverse=True) 
restaurants_list.sort(key = lambda x:x[0]) 
for i in range(N):
  print(restaurants_list[i][2])

Submission status: Accepted

Solution code:
n=int(input())
res_list=list()
for i in range(n):
  name, score = map(str, input().split())
  ll = {"index": i, "name": name, "score": int(score)}
  res_list.append(ll)

sorted_items = sorted(
  res_list,
  key = lambda x: (x['name'], -x['score'])
)

for s in sorted_items:
  print(s['index']+1)

Submission status: Accepted

Solution code:
n = int(input())
a = []

for i in range(n):
    s,p = map(str,input().split())
    a.append([i+1,s,int(p)])

a = sorted(a, key=lambda x:x[2], reverse=1)
a = sorted(a, key=lambda x:x[1], reverse=0)

for i in range(n):
    print(a[i][0])

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, p = LI()
    print((a*3+p)//2)
    return

#B
def B():
    n = II()
    sp = []
    for i in range(n):
        sp.append(input().split())
    another = [(s[0], -1 * int(s[1]),num) for num,s in enumerate(sp)]
    another.sort()
    for s,p,q in another:
        print(q+1)

    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    B()

Submission status: Accepted

Solution code:
N = int(input())

s_ps = {}
for n in range(N):
    s,p=input().split()
    p=int(p)

    if s_ps.get(s) is None:s_ps[s] = []

    s_ps[s].append((n,p))

for s, ps in sorted(s_ps.items(), key=lambda x:x[0]):
    for n, p in sorted(ps, key=lambda x:x[1]*-1):
        print(n+1)

Submission status: Accepted

Solution code:
N = int(input())

SP = []
for i in range(N):
    str = input().split()
    SP.append([str[0] ,int(str[1])*-1,i])

SP.sort()

for i in range(N):
    print(SP[i][2]+1)

Submission status: Accepted

Solution code:
n=int(input())
ans=[]
for i in range(n):
    s,p=input().split()
    ans.append([s,p,i+1])
ans.sort(key=lambda x:(x[0],-int(x[1])))
for i in range(n):
    print(ans[i][2])

Submission status: Accepted

Solution code:
def solve():
    N = int(raw_input())
    SP = []
    for i in range(N):
        SiPi = raw_input().split()
        Si = SiPi[0]
        Pi = int(SiPi[1])
        SP.append([Si, - Pi, i+1])
    SP.sort()
    for i in range(N):
        print SP[i][2]

if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
N = int(input())
SP = [list(input().split()) for _ in range(N)]

for i in range(N):
    SP[i] = [SP[i][0], int(SP[i][1]) * (-1), i+1]
SP.sort(key=lambda x: x[1])
SP.sort()

for i in range(N):
    print(SP[i][2])

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys

input = sys.stdin.readline

def main():
    N = int(input())
    cities = [[] for _ in range(N)]
    for i in range(N):
        s, p = list(input().split())
        cities[i] = [i+1, s, int(p)]
    cities.sort(key=lambda x: (x[1], 100 - x[2]))
    for c in cities:
        print(c[0])

main()

Submission status: Accepted

Solution code:
n = int(input())
rss = []
num = 1
for i in range(n):
  tmp = input().split(" ")
  tmp[1] = 100-int(tmp[1])
  tup = [tmp,num]
  rss.append(tup)
  num = num+1

rss.sort()

for i in range(n):
  print(rss[i][1])

Submission status: Accepted

Solution code:
from operator import itemgetter

n=int(input())
mylist=[]
for i in range(n):
    a,b=input().split()
    mylist.append([a,int(b),i])

mylist=sorted(mylist,key=itemgetter(1),reverse=True)

mylist=sorted(mylist,key=itemgetter(0))

for li in mylist:
    print(li[2]+1)

Submission status: Accepted

Solution code:
# 入力
N = int(input())
S, P = (
    zip(*(
        (s, int(p))
        for s, p in (input().split() for _ in range(N))
    )) if N else
    ((), ())
)

ans = '\n'.join(
    str(i)
    for _, _, i in sorted(
        zip(
            S,
            P,
            range(1, N + 1)
        ),
        key=lambda t: (t[0], -t[1])
    )
)

# 出力
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
book1={}
for i in range(1,N+1):
    string,point=input().split()
    point=int(point)
    if  string in book1.keys():
        book1[string][point]=i
    else:
        book1[string]={point:i}
for keys in sorted(book1.keys()):
    for point in sorted(book1[keys].keys(),reverse=True):
        print(book1[keys][point])

Submission status: Accepted

Solution code:
n=int(input())
l=[]
for i in range(n):
    l.append(list(input().split()))
    l[i][1]=int(l[i][1])*-1
    l[i].append(i+1)
l.sort()
for j in range(n):
    print(l[j][2])

Submission status: Accepted

Solution code:
n=int(input())
l=[]
for i in range(n):
    a,b=map(str,input().split())
    l.append([a,-int(b),i+1])
l.sort()
for i in range(n):
    print(l[i][2])

Submission status: Accepted

Solution code:
N = int(input())

list = []
for i in range(N):
    s, p = input().split()
    P = 100 - int(p)
    list.append((s,P,i+1))

list.sort()

for a in list:
    print(a[2])

Submission status: Accepted

Solution code:
N = int(input())
SP = []
for i in range(1, N+1):
    s, p = input().split()
    p = -int(p)
    SP.append([s, p, i])
 
SP.sort()
for t in SP:
    print(t[2])

Submission status: Accepted

Solution code:
def main():
	N = int(input())
	restaurants = []
	for i in range(N):
		S, P = input().split()
		p = int(P)
		restaurants.append([S, p, i+1])
	restaurants.sort(key=lambda x: (x[0], -x[1]))

	for r in restaurants:
		print(r[2])


if __name__ == '__main__':
	main()

Submission status: Accepted

Solution code:
def resolve():
    n = int(input())
    rests = []
    for i in range(1, n+1):
        o = input().split(" ")
        o[1] = (0 - int(o[1]))
        o.append(i)
        rests.append(o)

    rests = sorted(rests, key=lambda x: (x[0], x[1]))
    for i in range(n):
        print(rests[i][2])
    
if '__main__' == __name__:
    resolve()

Submission status: Accepted

Solution code:
n = int(input()) 
alllist=[]
for i in range(n):
    s,p = input().split()
    q=i+1
    relist=[]
    relist.append(str(s))
    relist.append(int(p))
    relist.append(int(i+1))
    alllist.append(relist)
alllist.sort(key=lambda x:x[1],reverse=True)
alllist.sort(key=lambda x:x[0])
for i in range(len(alllist)):
    print(alllist[i][2])

Submission status: Accepted

Solution code:
n = int(input())
nums = [[i+1] + list(input().split()) for i in range(n)]

nums.sort(key=lambda x: int(x[2]))
nums.reverse()
nums.sort(key=lambda x: x[1])


for elem in nums:
    print(elem[0])

Submission status: Accepted

Solution code:
N=int(input())
ls=[]
for i in range(N):
    s,p=input().split()
    ln=[str(s),int(p)]
    ls.append([i]+ln)
ls.sort(key=lambda x:(x[1],-x[2])) 
for lst in ls:
    print(lst[0]+1)

Submission status: Accepted

Solution code:
n = int(input())
l = [[i] + input().split() for i in range(n)]
#print(SP)
l.sort(key=lambda x:(x[1], -int(x[2])))
for i,s,p in l:
  print(i+1)

Submission status: Accepted

Solution code:
N = int(input())

sps = []
for i in range(N):
    tmp = input().split()
    s = tmp[0]
    p = int(tmp[1])
    sp = (i + 1,s,p)
    sps.append(sp)

sps = sorted(sps,key=lambda sp: (sp[1],-sp[2]))

for sp in sps:
    print(sp[0])

Submission status: Accepted

Solution code:
from operator import itemgetter
n = int(input())
l = []
for _ in range(n):
  s,p = map(str,input().split())
  p = int(p)
  l.append([s,p])
#print(l)
l1 = sorted(l,key=itemgetter(1),reverse=True)
#print(l1)
l2 = sorted(l1,key=itemgetter(0))
#print(l2)
for i in l2:
  print(l.index(i)+1)

Submission status: Accepted

Solution code:
N = int(input())
A = []
for i in range(1,N+1):
  c, s = input().split()
  s = 100 - int(s)
  A.append((c, s, i))
  
A.sort()
for a in A:
  print(a[2])

Submission status: Accepted

Solution code:
N=input()
N=int(N)
S=[100]*N
P=[100]*N
for num in range(N):
    S[num]=input().split()
    S[num].append(num+1)
    S[num][1]=int(S[num][1])

S.sort()
flag=0
flag2=0
while(flag==0):
    flag2=0
    for num in range(0,N-1):
        if(S[num][0]==S[num+1][0]):
            if(S[num][1]<S[num+1][1]):
                S[num],S[num+1]=S[num+1],S[num]
                flag2=1
    if(flag2==0):
        flag=1
    
            

for num in range(N):
    print(S[num][2])

Submission status: Accepted

Solution code:
N = int(input())
SP = []
for i in range(N):
    S, P = input().split()
    P = int(P)
    SP.append([S, P, i+1])

SP.sort()

while SP:
    restaurant = SP.pop(0)
    city = restaurant[0]
    point_num = [[restaurant[1], restaurant[2]]]
    while SP and SP[0][0] == city:
        restaurant = SP.pop(0)
        point_num.append([restaurant[1], restaurant[2]])

    point_num.sort(reverse=True)
    for i in point_num:
        print(i[1])

Submission status: Accepted

Solution code:
N = int(input())
restaurant = []
for i in range(0, N):
	shop = input().split()
	restaurant.append([i+1, shop[0], int(shop[1])])
restaurant.sort(key = lambda val: (val[1], -val[2]))
for i in range(0, N):
	print(restaurant[i][0])

Submission status: Accepted

Solution code:
n=int(input())
spi=[]

for i in range(n):
    S,P=input().split()
    spi+=[[S,int(P),i+1]]
spi.sort()
city=spi[0][0]
citys=[]
ans=[]
for s,p,i in spi:
    if city==s:
        citys+=[[p,i]]

    else:
        citys.sort(reverse=True)
        for x,y in citys:
            ans+=[y]

        city=s
        citys=[[p,i]]

citys.sort(reverse=True)
for x,y in citys:
    ans+=[y]

for i in ans:print(i)

Submission status: Accepted

Solution code:
inputNum = int(input())
shop = [0] * inputNum

for num in range(inputNum):
    city, score = input().split(" ")
    shop[num] = {'ID' : num + 1, 'City' : city, 'Score' : score}

sort_shop = sorted(shop, key = lambda x:-int(x['Score']))
sort_shop =sorted(sort_shop, key = lambda x:x['City']) 

for answer in sort_shop:
    print(answer['ID'])

Submission status: Accepted

Solution code:
N=int(input())
l=[]
for i in range(N):
	s,p=input().split()
	l.append([i+1,s,int(p)])

l.sort(key=lambda x:x[2],reverse=True)
l.sort(key=lambda x:x[1])

for i in l:
	print(i[0])

Submission status: Accepted

Solution code:
from operator import itemgetter

def input_list(num,args):
    for i in range(num):
        S,P = input().split()
        P=int(P)
        if 1<=len(S)<=10 and S.islower()==1 and S.isalpha()==1 \
           and 0<=P<=100 and isinstance(P,int)==1:
            args.append([S,P])
        else :
            print("ERROR")
            exit()



def sort_list(*args):
    tmp=sorted(args,key=itemgetter(1),reverse=1)
    dict_sorted=sorted(tmp,key=itemgetter(0))

    return dict_sorted


def check_list(seq):
    seen = []
    unique_list = [x for x in seq if x not in seen and not seen.append(x)]
    if len(seq) != len(unique_list):
        print("ERORR")
        exit()
    # else :                                                                                         
    #     print("restaurant is ok.")           



def main():
    # restaurant=[['N1',88],['N2',85],['N3',92],['N7',21],['N4',34],['N8',45],['N2',24],['N2',35]]   
    # num=8                                                                                          

    num=int(input())
    if 1<=num<=100:
        # [[] for i in range(5)]                                                                     
        restaurant=[]
        input_list(num,restaurant)

        check_list(restaurant)

        # print(restaurant)                                                                          
        restaurant_sorted=sort_list(*restaurant)

        for i in range(num):
            for j in range(num):
                if restaurant_sorted[i][1]==restaurant[j][1]:
                    print(j+1)
    else :
        print("ERORR")
        exit()

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from collections import defaultdict

res_dic = defaultdict(list)

num = input()

for i in range(int(num)):
    s = input()
    lis = s.split()
    res_dic[lis[0]].append([i+1, int(lis[1])])

res_dic = sorted(res_dic.items(), key=lambda x:x[0])

for k, l in res_dic:
    ls = sorted(l, key=lambda x:-x[1])
    for id, v in ls:
        print(id)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
restaurants = []
for i in range(n):
    s, p = input().split()
    restaurants.append((s, -int(p), i))
restaurants = sorted(restaurants)
for r in restaurants:
    print(r[2] + 1)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int, S: "List[str]", P: "List[int]"):
    sp = sorted(
        [(s, p, index) for (s, p, index) in zip(S, P, range(1, N + 1))],
        key=lambda x: (x[0], -x[1]),
    )
    for s, p, index in sp:
        print(index)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [str()] * (N)  # type: "List[str]"
    P = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        S[i] = next(tokens)
        P[i] = int(next(tokens))
    solve(N, S, P)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:

import numpy

N = int(input())

scores = {}
indexes = {}
for i in range(N):
    s, p = input().split()
    p = int(p)
    if s in scores:
        scores[s].append(p)
        indexes[s].append(i)
    else:
        scores[s] = [p]
        indexes[s] = [i]

# print(scores)
# print(indexes)

# scores = {'khabarovsk': [20, 40], 'moscow': [10, 60], 'kazan': [50, 35]}
# indexes = {'khabarovsk': [0, 5], 'moscow': [1, 4], 'kazan': [2, 3]}
# N = 6

for s in sorted(scores.keys()):
    for i in numpy.argsort(scores[s])[::-1]:
        print(indexes[s][i]+1)