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:
A = int(input())
l = []
for i in range(A):
    A = input().split()
    B = int(A[1])
    A = A[0]
    l.append([A,B])
l_after = list(l)
l_after.sort(key=lambda x:(x[0],-x[1]))
for i in l_after:
    print(l.index(i)+1)

Submission status: Accepted

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

A = sorted(SP, key = lambda x : x[1], reverse = True)
A = sorted(A, key = lambda x : x[0])

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

Submission status: Accepted

Solution code:
n=int(input())
lists=[]
for x in range(n):
  a,b=input().split()
  lists.append([a,int(b),x+1])
lists.sort(key=lambda t:t[1],reverse=True)
lists.sort(key=lambda t:t[0])
for x in range(n):
  print(lists[x][2])

Submission status: Accepted

Solution code:
N = int(input())
l = []
for i in range(N):
  a,b = input().split()
  l.append([a, int(b), i + 1])
l.sort(key=lambda x: x[1], reverse=True)
l.sort(key=lambda x: x[0])
for i,j,k in l:
  print(k)

Submission status: Accepted

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

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

for i in range(N):
    print(restaurant[i][0])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
s = []
c = {}
nums = {}
for i in range(n):
    ipt = input().split()
    nums[int(ipt[1])] = i + 1
    if not ipt[0] in c:
        s.append(ipt[0])
        c[ipt[0]] = [int(ipt[1])]
    else:
        c[ipt[0]].append(int(ipt[1]))

s.sort()

for i in s:
    c[i].sort()
    for j in c[i][::-1]:
        print(nums[j])

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1


N = int(input())
info_list = []

for i in range(N):
    city, point = map(str, input().split())
    info_list.append([city, int(point), i+1])

# Point-Sort => City Sort
info_list.sort(key=lambda x: x[1], reverse=True)
info_list.sort(key=lambda x: x[0])

for info in info_list:
    print(info[2])

Submission status: Accepted

Solution code:
n=int(input())
sp=[]
for i in range(n):
    s,p=map(str,input().split())
    sp.append([s,int(p),i+1])
sp.sort(key=lambda x: x[1],reverse=True)
sp.sort(key=lambda x: x[0])

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

Submission status: Accepted

Solution code:
import sys
import math
from collections import Counter
import itertools
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

# ###########################################

n = int(input())
sp = [0] * n
for i in range(n):
    sp[i] = list(map(str,input().split()))
    sp[i].append(i+1)
    sp[i][1] = int(sp[i][1])
    
sp.sort(key = lambda x: x[1],reverse = True)
sp.sort(key = lambda x: x[0])
for i in range(n):
    print(sp[i][2])

Submission status: Accepted

Solution code:
n = int(input())
sp = [0] * n
for i in range(n):
    sp[i] = list(map(str,input().split()))
    sp[i].append(i+1)
    sp[i][1] = int(sp[i][1])

sp.sort(key = lambda x: x[1],reverse = True)
sp.sort(key = lambda x: x[0])
for i in range(n):
    print(sp[i][2])

Submission status: Accepted

Solution code:
n = int(input())
sp = [input().split() + [i] for i in range(n)]
for i in sp:
    i[1] = int(i[1])
sp.sort(key=lambda x: x[1], reverse=True)
sp.sort(key= lambda x: x[0])
for i in sp:
    print(i[2] + 1)

Submission status: Accepted

Solution code:
from operator import itemgetter

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

def multisort(target_list, specs):
    for key, reverse in reversed(specs):
        target_list.sort(key=key, reverse=reverse)
    return target_list

temp_list = multisort(temp_list, ((itemgetter(1), False), (itemgetter(2), True)))

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

Submission status: Accepted

Solution code:
n = int(input())
x =[]
for i in range(n):
    a,b=input().split()
    b=int(b)
    x.append([i+1,a,b])
    x.sort(key=lambda x:x[2],reverse = True)
    x.sort(key=lambda x:x[1])
for i in range(n):
    print(x[i][0])

Submission status: Accepted

Solution code:
from operator import itemgetter

n = int(input())

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

temp_list.sort(key=itemgetter(2), reverse=True)
temp_list.sort(key=itemgetter(1))

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

Submission status: Accepted

Solution code:
n = int(input())
sp = []
for i in range(n):
    s, p = input().split()
    sp.append((s, -int(p), i))#sortedが昇順になるためpを-にする

res = sorted(sp)
for i in range(n):
    print(res[i][2]+1)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
SR = []
for i in range(1,N+1):
    s, r = input().split()
    SR.append((s,-int(r),i))

SR.sort(key=lambda x: (x[0],x[1]))
for ans in SR:
    print(ans[2])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
inp = [input() for i in range(N)]

import numpy as np

s_list = []
p_list = []
for i in inp:
    s_list.append(i.split()[0])
    p_list.append(int(i.split()[1]))

sp_list = []
for i in range(N):
    sp_list.append([s_list[i],p_list[i]])

# 市を辞書順
sort_sp_list = sorted(sp_list)

# 市の種類
s_type = sorted(list(set(s_list)))
tmp_list = []
for type in s_type:
    tmp_list.append(sorted([s for s in sort_sp_list if s[0] == type],reverse=True))

rank_list = []
for tmp in tmp_list:
    for l in tmp:
        rank_list.append(l)

for rank in rank_list:
    print(sp_list.index(rank)+1)

Submission status: Accepted

Solution code:
import numpy as np
N=int(input())
S_list=[]
T_point=[]
zisho = "abcdefghijklmnopqrstuvwxyz"
for i in range(N):
  SP = input().split()
  S_list.append(SP[0])
  zisho_num = 0
  for k in range(len(SP[0])):
    zisho_num = zisho_num + (zisho.index(SP[0][len(SP[0])-k-1])+1)*(100**(k+10-len(SP[0])))
  T_point.append(zisho_num*100+100-int(SP[1]))
T_point = np.array(T_point)
ind = T_point.argsort()
for i in range(N):
  print(ind[i]+1)

Submission status: Accepted

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

Submission status: Accepted

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

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

for r in sorted(rs):
    print(r[1])

Submission status: Accepted

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

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

for r in sorted(rs):
    print(r[2])

Submission status: Accepted

Solution code:
import sys

n = int(input())
rs = [ [i+1, input().split()] for i in range(n) ]
#print(rs)

rs = sorted(rs, key=lambda a:int(a[1][1]), reverse=True)
rs = sorted(rs, key=lambda a:a[1][0])

for r in rs:
    print(r[0])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
sp = [input().split() for i in range(n)]
for i in range(n):
    sp[i][1] = -1 * int(sp[i][1])
    sp[i].append(i+1)

sp.sort()


for i in range(n):
  print(sp[i][2])

Submission status: Accepted

Solution code:
# B - Guidebook

n = int(input())
r = []

for i in range(1, n+1):
    city, point = map(str, input().split())
    r.append(list((i, city, int(point))))

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

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

Submission status: Accepted

Solution code:
#bA
N = int(input())
SPN = []
for i in range(N):
    S, P = input().split()
    SPN.append([S, int(P), i+1])
SPN.sort(key = lambda SPN:(SPN[0], -SPN[1]))
for i in SPN:
    print(i[2])

Submission status: Accepted

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

for i in range(1,n+1):
    S,P=input().split()
    A.append((S,-int(P),i))

B=sorted(A)
for f in range(n):
    print(B[f][2])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
data = [None] * N
for i in range(N):
  data[i] = list(input().split()) + [i+1]
  
data = sorted(data,key=lambda x:(x[0],-int(x[1])))
for d in data:
  print(d[2])

Submission status: Accepted

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

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

l = sorted(l)

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

Submission status: Accepted

Solution code:
n = int(input())

map_list = [[0,'abc',0] for i in range(n)]

for i in range(n):
    input_line = input().split()
    map_list[i]=[i,input_line[0],int(input_line[1])]

ans_li = sorted(map_list,key=lambda x:(x[1],-x[2]))
for ans in ans_li:
    print(ans[0]+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    L=[]
    for i in range(N):
        S,T=ST().split()
        T=int(T)
        L.append((S,T,i))
    L.sort(reverse=True,key=lambda x:x[1])
    L.sort(key=lambda x:x[0])
    print(*[i+1 for x,y,i in L],sep="\n")

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())

guidebook = list()
for num in range(n):
    s = input().split()
    new_page = [s[0], -int(s[1]), int(num + 1)]
    guidebook.append(new_page)
sorted_data = sorted(guidebook, key=lambda x:(x[0], x[1]))

for page in sorted_data:
    print(page[2])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#ジュっピー
n = int(input())
sp = []#操作用の配列
for i in range(n):
    s,p = map(str,input().split())
    sp.append([s,int(p),i+1])
    #操作用の配列にデータを入れる
    #都市名、得点（整数化）、順番(i)は１始まりに
#ソート順に注意、重要なソートほど、後にする
sp.sort(key=lambda x:x[1],reverse = True)#最初に、得点の降順
sp.sort(key=lambda x:x[0])#重要な都市名の辞書順の昇順ソートは後回し

for e in sp:#操作用配列の１個１個の要素をeとして処理
    print(e[2])#i番目に紹介されるレストランの番号を出力

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
n = int(input())
l = [input().split() for _ in range(n)]
for i in range(n):
    l[i][1] = 100 - int(l[i][1])
m = sorted(l, reverse = True)
for i in range(n):
    for j in range(n):
        if m[n - i - 1] == l[j]:
            print(j + 1)

Submission status: Accepted

Solution code:
import time
startTimeProblem=time.time()

import fileinput, sys, itertools
from math import *
from bisect import *
from heapq import *
from collections import *

def lcm(a, b):  
    return (a*b)/gcd(a, b)

class InputHelper:
    def __init__(self):
        self.myinput = fileinput.input()

    def isLocal(self):
        return not fileinput.isstdin()

    def int(self):
        return int(self.myinput.readline().rstrip())

    def ints(self):
        return [int(_) for _ in self.myinput.readline().rstrip().split()]

    def str(self):
        return self.myinput.readline().rstrip()

    def strs(self):
        return [_ for _ in self.myinput.readline().rstrip().split()]

class OutputHelper:
    def int(self, a):
        print(a)    

    def ints(self, a):  
        print(" ".join([str(_) for _ in a]))
    
    def intsNL(self, a):
        for _ in a:
            print(_)
    
    def str(self, s):
        print(s)

    def strs(self, s):
        print(" ".join([_ for _ in s]))

    def strsNL(self, s):
        for st in s:
            print(st)

class ListNode:
    def __init__(self, val):
        self.val = val
        self.next = None
        self.prev = None

In = InputHelper()
Out = OutputHelper()

######################################

N = In.int()
arr = []

for i in range(1, N+1):
    line = In.str().split()

    arr.append((i, line[0], int(line[1])))

arr.sort(key=lambda x: (x[1], -x[2]))

res = [x[0] for x in arr]

Out.intsNL(res)


######################################

if len(sys.argv)>2 and sys.argv[2]=="TIMEIT":
    fin = (time.time()-startTimeProblem)*1000
    print("{:.2f}".format(fin) + "ms")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
SP = [input().split() for _ in range(N)]

for i in range(1, N+1):
	SP[i-1].append(i)

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
l=list()
for i in range(n):
    s,p=input().split()
    p=int(p)
    l.append([i+1,s,p])
l.sort(key=lambda x:(x[1],-x[2]))# 複数のキーでソートしたい時　昇順と降順を混ぜたい時はマイナスつける
for i in l:
    print(i[0])

Submission status: Accepted

Solution code:
N = int(input())
s = list()

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

s = sorted(s, key=lambda x: (x[0], -x[1]))  # 複数のキーでソートしたい時　昇順と降順を混ぜたい時はマイナスつける

for a in range(N):
    print(s[a][2])

Submission status: Accepted

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

Rs.sort()

for _, _, i in Rs:
    print(i)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
N = int(input())
list = []
for i in range(N):
    L = input().split()
    list.append([i+1, L[0], int(L[1])])

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

for k in range(N):
    print(list[k][0])

Submission status: Accepted

Solution code:
# ABC 128: B – Guidebook
N = int(input())

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

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

for k in [shop[0] for shop in shops]:
    print(k)

Submission status: Accepted

Solution code:
N = int(input())

d = {}
S = set()

for i in range(N):
    s,p = input().split()
    p = int(p)
    S.add(s)
    if s in d:
        d[s].append([p, i+1])
        continue
    d[s] = []
    d[s].append([p, i+1])
S = list(S)
S.sort()

for key in S:
    L = d[key]

    L = sorted(L, reverse=True)
    for l in L:
        print(l[1])

Submission status: Accepted

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

for i in range(n):
    s,p = input().split()
    rc.append((str(s),int(p)))

rc = (list(enumerate(rc)))

rc.sort(key=lambda x:x[1][1], reverse=True)
rc.sort(key=lambda x:x[1][0], reverse=False)

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

Submission status: Accepted

Solution code:
N=int(input())
l=[]
for i in range(N):
    S,P=input().split()
    l.append((S,-int(P),i+1))
l.sort()
for i in l:
    print(i[2])

Submission status: Accepted

Solution code:
N = int(input())
li =[]
for i in range(N):
    s, n = input().split()
    li.append([s, int(n), i+1])
li2 = sorted(li, key=lambda x: x[1], reverse=True)
li3 = sorted(li2, key=lambda x: x[0])
for i in range(N):
    print(li3[i][2])

Submission status: Accepted

Solution code:
N = int(input())

A = []
for i in range(1,N+1):
  a=list(input().split())
  a.append(str(i))
  A.append(a)

A.sort(key=lambda x: int(x[1]), reverse=True)
A.sort(key=lambda x: x[0])
#print(A)
for i in range(N):
  print(A[i][2])

Submission status: Accepted

Solution code:
def solve():
    N = int(input())
    S = [0]*N
    for i in range(N):
        S[i] = input().split()
        S[i][1] = int(S[i][1])
    T = sorted(S, key=lambda x:(x[0],-x[1]))
    ans = []
    for t in T:
        ind = S.index(t)
        ans.append(ind+1)
    return ans
print(*solve(),sep='\n')

Submission status: Accepted

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

Submission status: Accepted

Solution code:

n = int(input())
rs = []
for i in range(n):
    s, p = input().split()
    p = int(p)
    rs.append((s, -p, i+1))
rs = sorted(rs)
for r in rs:
    print(r[2])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
s = [input().split() for i in range(n)]
s = [[i, -int(j), x] for x, (i, j) in enumerate(s)]
s.sort()
for i, j, x in s:
  print(x+1)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
a = int(input())
d = [list(input().split()) for i in range(a)]
d = [[i,-int(j),x] for x,(i,j) in enumerate(d)]
d.sort()
for i,j,k in d:
    print(k+1)

Submission status: Accepted

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

Submission status: Accepted

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

for s,p,i in rest_list:
  print(i)

Submission status: Accepted

Solution code:


n = int(input())

ls = []

for i in range(n):

    s, p = input().split()

    ls.append([i+1, s, int(p)])

ls = sorted(ls, key=lambda x: (x[1], -x[2]))
    
for l in ls:
    print(l[0])

Submission status: Accepted

Solution code:
icase=0
if icase==0:
    from operator import itemgetter
    n=int(input())
    sp=[]
    for i in range(n):
        si,p=input().split()
        sp.append([si,int(p),i]) 
    sp.sort(key=itemgetter(1),reverse=True)
    sp.sort(key=itemgetter(0))
#    sp.sort()
    for i in range(n):
#        print(sp[i][2]+1,sp[i][0],sp[i][1])
        print(sp[i][2]+1)

Submission status: Accepted

Solution code:
N = int(input())
arr = [[0, 0, 0]] * N

for i in range(N):
    arr[i] = input().split()
    arr[i][1] = int(arr[i][1])
    arr[i].append(i + 1)

ans = sorted(arr, key = lambda a: (a[0], -1 * a[1]))

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

Submission status: Accepted

Solution code:
n = int(input())
lst = []
for i in range(1,n+1):
  s,p = input().split()
  lst.append((s,150-int(p),i))
lsts = sorted(lst)
for j in range(n):
  print(lsts[j][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,i,r in p:
  print(r+1)

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])
    
for i in sorted(SP):
    print(SP.index(i)+1)

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7


def main():
  N = int(readline())
  A = []
  for i in range(N):
    s, p = input().split()
    p = int(p)
    A.append((s, -p, i+1))
  A.sort()
  for s, p, i in A:
    print(i)
  
if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
N = int(input())  
sps = []
ss = []
for i in range(1, N+1):
    s, p = input().split(' ')
    sps.append([i, s, int(p)])
    if s not in ss:
        ss.append(s)

sps = sorted(sps, key=lambda x: x[2], reverse=True)
ss = sorted(ss)
ret = []
for s in ss:
    t = [tmp for tmp in sps if tmp[1]==s]
    ret.extend(t)

for i in range(N):
    print(ret[i][0])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
d = {}
l = []
for i in range(n):
    a, b = input().split()
    if a not in l:
        l.append(a)
        d[a] = set([(int(b), i + 1)])
    else:
        d[a].add((int(b), i + 1))
l.sort()
for i in range(len(l)):
    d[l[i]] = list(d[l[i]])
    d[l[i]].sort(reverse=True)
    for j in range(len(d[l[i]])):
        print(d[l[i]][j][1])

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
def myAnswer(N:int,guidebook:dict) -> None:
   ans = sorted(guidebook.items())
   for _,ary in ans:
      tmp = sorted(ary.items(),reverse=True)
      for t in tmp:
         print(t[1])
      

def modelAnswer():
   tmp=1
def main():
   N = int(input())
   guidebook = {}
   for n in range(N):
      s,p = map(str,input().split())
      if(s in guidebook.keys()):
         guidebook[s][int(p)]=n+1
      else:
         guidebook[s]={int(p):n+1}
   myAnswer(N,guidebook)


if __name__ == '__main__':
   main()

Submission status: Accepted

Solution code:
n = int(input())
guide = []
for i in range(n):
   restaurant = []
   s, p = input().split()
   p_1 = int(p)
   restaurant.append(s)
   restaurant.append(p_1)    
   x = i+1
   restaurant.append(x)
   guide.append(restaurant) 
sort_guide = sorted(guide, key=lambda x:(x[0],-x[1]))
for i in range(len(sort_guide)):
    print(sort_guide[i][2])

Submission status: Accepted

Solution code:
N=int(input())
scores=[]
for _ in range(N):
    s,p=input().split()
    scores.append((s.strip(),int(p)))
rank=sorted(scores,key=lambda x:(x[0],-x[1]))
for i in rank:
    print(int(scores.index(i))+1)

Submission status: Accepted

Solution code:
N=int(input())
scores=[]
for _ in range(N):
    s,p=input().split()
    scores.append((s.strip(),int(p)))
rank=sorted(scores,key=lambda x:(x[0],-x[1]))
for i in rank:
    print(int(scores.index(i))+1)

Submission status: Accepted

Solution code:
n=int(input())
array1=[[i+1]+input().split() for i in range(n)]
array1.sort(key=lambda x:(x[1],-int(x[2])))
for a,b,c in array1:
            print(a)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
class Restaurant:
    def __init__(self, id, city, score):
        self.id = id
        self.city = city
        self.score = score

    def __lt__(self, other):
        if (self.city != other.city):
            return self.city < other.city
        else:
            return self.score > other.score


n = int(input())
restaurants = list()
for i in range(n):
    tmp = input().split()
    c = tmp[0]
    s = int(tmp[1])
    restaurants.append(Restaurant(i + 1, c, s))

restaurants.sort()

for r in restaurants:
    print(r.id)

Submission status: Accepted

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

sp.sort(key=lambda x: x[1], reverse=True)
sp.sort(key=lambda x: x[0])

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

Submission status: Accepted

Solution code:
N = int(input())
SP = []
for i in range(N):
    S, P = input().split()
    SP.append([S, int(P), i + 1])
# SP = [[input().split(), i] for i in range(N)]
SP.sort(key=lambda x: (x[0], -x[1]))
num = list(zip(*SP))[-1]
for i in num:
    print(i)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

s = {}
for i in range(n):
    tmp, temp = input().split()
    if tmp not in s.keys():
        s[tmp] = [(i, int(temp))]
    else:
        s[tmp] += [(i, int(temp))]
    
    
s = sorted(s.items(), key=lambda x:x[0])

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

Submission status: Accepted

Solution code:
n = int(input())

sp = []
for i in range(n):
    s, p = map(str, input().split())
    sp.append([s, int(p), i + 1])
    
sp.sort(key=lambda x:x[1], reverse=True)
sp.sort(key=lambda x:x[0])

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

Submission status: Accepted

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