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())
S = [(i, tuple(input().split())) for i in range(1, N + 1)]

arr = sorted(S, key=lambda item: int(item[1][1]), reverse=True)
arr2 = sorted(arr, key=lambda item: item[1][0])

for item in arr2:
    print(item[0])

Submission status: Accepted

Solution code:
n = int(input())

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

s.sort()

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

Submission status: Accepted

Solution code:
N = int(input())
lst = []
for i in range(1,N+1):
  S,P = input().split()
  #一つのリストとしてlstに追加する、番号もつけて
  lst.append([S,-1*int(P),i])

lst = sorted(lst,key=lambda x:(x[0],x[1]))
for i in lst:
  print(i[2])

Submission status: Accepted

Solution code:
n = int(input())
l = []
for i in range(n):
    l.append([i for i in input().split()])

for i in range(n):
    l[i][1] = 100 -int(l[i][1])

for i in range(n):
    l[i].append(int(i))

for i in sorted(l):
    print(i[2] + 1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

N=int(input())

restaurant={}

for i in range(N):
  temp=input().split()
  restaurant.setdefault(temp[0], []).append([int(i+1), int(temp[1])])
  
keys=[]
for key in restaurant:
  keys.append(key)
  
keys.sort()
for key in keys:
  temp=np.array(restaurant[key])
  temp=temp[np.argsort(temp, axis=0)[::-1, 1]]
  for i in range(temp.shape[0]):
    print(temp[i, 0])

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])
l1=sorted(l,key=lambda x:x[1],reverse=True)
l2=sorted(l1,key=lambda x:x[0])
for i in range(N):
  print(l.index(l2[i])+1)

Submission status: Accepted

Solution code:
n = int(input())
R = [list(input().split()) for i in range(n)]
for i in range(n):
  R[i][1] = int(R[i][1])
sR = sorted(R, key=lambda x: x[1], reverse=True)
sR = sorted(sR, key=lambda x: x[0])
A = []
for i in range(n):
  print((R.index(sR[i]) + 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, i + 1))
sp = sorted(sp, key=lambda a: (a[0], -a[1]))
for _, _, i in sp:
    print(i)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

restaurants = []

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

restaurants = sorted(restaurants, key=lambda x: (x[1], -x[2]))

for i in range(len(restaurants)):
    print(restaurants[i][0])

Submission status: Accepted

Solution code:
from operator import itemgetter

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

SP.sort(key=itemgetter(1, 2))
for x in SP:
    print(x[0] + 1)

Submission status: Accepted

Solution code:
from operator import itemgetter

N = int(input())
SP = []
for i in range(N):
    s, p = input().split()
    p = int(p)
    SP.append([i, s, p])

D = {}
for i, s, p in SP:
    if not D.get(s):
        D[s] = []
    D[s].append([i, p])

for k, v in D.items():
    v.sort(key=itemgetter(1), reverse=True)

S = sorted(D.keys())
# print(D)
# print(S)

for si in S:
    ds = D.get(si)
    for i, v in ds:
        print(i + 1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

data = []
for i in range(N):
    name, point = input().split()
    data.append({'id': i + 1, 'name': name, 'point': 100 - int(point)})

data.sort(key=lambda x: [x['name'], x['point']])

res = [d['id'] for d in data]

print(*res, sep='\n')

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(*[s[2] for s in l],sep='\n')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict

dic = defaultdict(list)
n = int(input())

for no in range(1, n+1):
    city, point = input().split()
    dic[city].append([int(point), no])

for city in sorted(dic):
    for point, no in sorted(dic[city], reverse=True):
        print(no)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict
n = int(input())

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

for key in dct.keys():
    dct[key].sort()
    dct[key].reverse()
dct = sorted(dct.items())

for store in dct:
    for p in store[1]:
        print(score.index(p)+1)

Submission status: Accepted

Solution code:
N = int(input())
S = [0] * N
P = [0] * N

n = [i for i in range(N)]

for i in range(N):
    S[i], P[i] = input().split()
    P[i] = int(P[i])

items = zip(S, P, n)
items = sorted(items, key = lambda x:(x[0], -x[1]))

for S, P, n in items:
    print(n + 1)

Submission status: Accepted

Solution code:
n = int(input())
info = {}
point = {}
for i in range(n):
  s, p = input().split()
  point[int(p)] = i+1
  if s not in info:
    info[s] = [int(p)]
  else:
    info[s].append(int(p))
   
for city in sorted(info.keys()):
  for p in sorted(info[city], reverse=True):
    print(point[p])

Submission status: Accepted

Solution code:
n=int(input())
A=[[0]*3 for i in range(n)]
for i in range(n):
    a,b=map(str,input().split())
    b=int(b)
    A[i][0],A[i][1],A[i][2]=a,-b,i+1
A.sort()

for i,a in enumerate(zip(*A)):
	if i==2:print(*a,sep='\n')

Submission status: Accepted

Solution code:
from operator import itemgetter
n = int(input())
restaurants = []
for i in range(n):
    a,b = input().split()
    restaurants.append([i,a,int(b)]) #{市名：得点}

for restaurant in sorted(sorted(restaurants,key = itemgetter(2),reverse=True),key = itemgetter(1)):
    print(restaurant[0]+1)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

from collections import deque

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())

class Restaurant:
    def __init__(self, id=None, name=None, score=None):
        self.id = id
        self.name = name
        self.score = score

r = [None for _ in range(n)]

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

r.sort(key=lambda x:(x.name, -x.score))

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

Submission status: Accepted

Solution code:
import sys


def solve(N: int, S: "List[str]", P: "List[int]"):
    data = list(zip(S, map(lambda x: -x, P), range(1, N + 1)))
    data.sort()
    return "\n".join(str(t[2]) for t in data)


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))
    ans = solve(N, S, P)
    if ans is not None:
        print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())

cookbook = [0] * N

for n in range(N):
    line = input().split()
    s = line[0]
    p = int(line[1])
    cookbook[n] = (n + 1, s, p)

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(N):
  print(A[i][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 = sorted(sp, key=lambda x: x[1], reverse=True)
sp = sorted(sp, key=lambda x: x[0])
for i in sp:
    print(i[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 a,p,i in l:
    print(i)

Submission status: Accepted

Solution code:
def solve():
  n = int(input())
  query = []
  for i in range(n):
    s,p = input().split()
    query.append((s+str(900-int(p)),i+1))
  query.sort()
  for i in range(n):
    print(query[i][1])
solve()

Submission status: Accepted

Solution code:
def solve():
  n = int(input())
  query = []
  for i in range(n):
    tmp = input()
    s,p = tmp.split()
    p = str(90000000-int(p))
    s = s+p
    query.append((s,i+1))
  query.sort()
            
    
  for i in range(n):
    print(query[i][1])
solve()

Submission status: Accepted

Solution code:
def solve():
  n = int(input())
  query = []
  for i in range(n):
    tmp = input()
    s,p = tmp.split()
    query.append((s,p,i+1))
  query.sort()
  count = 0
  while count<n/2:
    count += 1
    for i in range(n):
      for j in range(i+1,n):
        if query[i][0] == query[j][0]:
          if int(query[i][1]) <int(query[j][1]):
            buf = query[i]
            query[i] = query[j]
            query[j] = buf
            
    
  for i in range(n):
    print(query[i][2])
solve()

Submission status: Accepted

Solution code:
def solve():
  n = int(input())
  query = []
  for i in range(n):
    tmp = input()
    s,p = tmp.split()
    query.append((s,p,i+1))
  query.sort()
  count = 0
  while count<n:
    count += 1
    for i in range(n):
      for j in range(i+1,n):
        if query[i][0] == query[j][0]:
          if int(query[i][1]) <int(query[j][1]):
            buf = query[i]
            query[i] = query[j]
            query[j] = buf
            
    
  for i in range(n):
    print(query[i][2])
solve()

Submission status: Accepted

Solution code:
def solve():
  n = int(input())
  query = []
  for i in range(n):
    tmp = input()
    s,p = tmp.split()
    query.append((s,p,i+1))
  query.sort()
  count = 0
  while count<1000:
    count += 1
    for i in range(n):
      for j in range(i+1,n):
        if query[i][0] == query[j][0]:
          if int(query[i][1]) <int(query[j][1]):
            buf = query[i]
            query[i] = query[j]
            query[j] = buf
            
    
  for i in range(n):
    print(query[i][2])
solve()

Submission status: Accepted

Solution code:
N = int(input())
list_r = []
for i in range(N):
    a,b = input().split()
    list_r.append((i+1, a, int(b)))
sorted_list=sorted(list_r, key=lambda x:(x[1],-x[2]))

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    S, P = [], []
    for _ in range(N):
        si, pi = input().split()
        S.append(si)
        P.append(int(pi))

    d = dict()
    for i in range(N):
        if S[i] not in d:
            d[S[i]] = [[P[i], i+1]]
        else:
            d[S[i]].append([P[i], i+1])
    output = []

    cities = sorted(d.keys())
    for c in cities:
        output += [x[1] for x in sorted(d[c], key = lambda x: x[0], reverse = True)]
    return output

if __name__ == '__main__':
    output = main()
    for i in range(len(output)):
        print(output[i])

Submission status: Accepted

Solution code:
def test():
    n = int(input())
    a = []
    for i in range(n):
        a.append(input().split())
    b = sorted(a,key = lambda x: (x[0],-int(x[1])))
    for i in range(n):
        print(a.index(b[i])+1)


if __name__ == "__main__":
    test()

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.readline

N = int(input())
P = []
for i in range(N):
    n,v = input().split()
    P.append((n, int(v), i+1))
P = sorted(P, key=lambda x:x[1], reverse=True)
P = sorted(P, key=lambda x:x[0])
for n,v,i in P:
    print(i)

Submission status: Accepted

Solution code:
from collections import defaultdict
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n = int(input())
SP = [[x for x in input().split()] for _ in range(n)]
ans_list = defaultdict(list)
for i, sp in enumerate(SP):
    ans_list[sp[1]] = i

li = sorted(SP, key=lambda x: -int(x[1]))
li = sorted(li, key=lambda x: x[0])
#print(li)
#print(ans_list)
for x in li:
    print(ans_list[x[1]]+1)

Submission status: Accepted

Solution code:
n = int(input())
a = [list(input().split()) for i in range(n)]
d = sorted(set([i[0] for i in a]))
for i in a:
  for j in range(len(d)):
    if i[0] == d[j]:
      i[0] = 10000**(len(d)-(j+1))
c = [i[0]*int(i[1]) if int(i[1]) != 0 else i[0]*0.1 for i in a ]
e = sorted(c,reverse=True)
for i in e:
  print(c.index(i)+1)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

for v in ls:
  print(v[2])

Submission status: Accepted

Solution code:
#B - Guidebook(ABC128)
N=int(input())
X=[]
for i in range(N):
    s,t=map(str, input().split())
    X.append([s,int(t)*-1,i+1])
for i in range(N):
    print(sorted(X)[i][2])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#coding:utf-8
n = int(input())
restaurant = []

for i in range(n):
    city, point = input().split()
    point = int(point)
    restaurant.append([city, point, i+1])

#print(restaurant)
#町は昇順、点数は降順　片方だけ降順にするときはキーにマイナスをつける
rank = sorted(restaurant, key=lambda x:(x[0],-x[1]))
#print(rank)

for _, _, number in rank:
    print(number)

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], reverse=True)
Sp.sort(key = lambda x: x[0])

for sp in Sp:
    print(sp[2]+1)

Submission status: Accepted

Solution code:
import os,re,sys,operator,math
from collections import Counter,deque
from operator import itemgetter
from itertools import accumulate,combinations,groupby
from sys import stdin,setrecursionlimit
from copy import deepcopy
import heapq
import string

setrecursionlimit(10**6)

n=int(stdin.readline().rstrip())
town=[]
for i in range(n):
    p,g=stdin.readline().rstrip().split()
    town.append((p,int(g),i+1))
town.sort(key=lambda x:(x[0],-x[1]))
for i in town:
    print(i[2])

Submission status: Accepted

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

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

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

for j in di:
    print(j[2])

Submission status: Accepted

Solution code:
from collections import defaultdict
N = int(input())
d = defaultdict(list)
p2n = {}
for n in range(N):
  s, p = input().split()
  d[s].append(int(p))
  p2n[int(p)] = n + 1

for key in sorted(d):
  for p in sorted(d[key],reverse=True):
    print(p2n[p])

Submission status: Accepted

Solution code:
n = int(input())
s = [input().split() for _ in range(n)]

# レストラン番号を付加する 点数を整数化する
for i in range(n):
  s[i].append(i+1)
  s[i][1] = int(s[i][1])
# 配列要素の1番目(点数)でソートする
s.sort(key = lambda x:x[1], reverse=True)
# 配列要素の０番目(レストラン名)でソートする
s.sort(key = lambda x:x[0])

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

Submission status: Accepted

Solution code:
from operator import itemgetter

N = int(input())
SP = []
lst = []
for i in range(N):
  lst = list(input().split())
  lst.append(i+1)
  SP.append(lst)
  SP[i][1] = int(SP[i][1])
SP = sorted(SP, key=itemgetter(1), reverse=True)
SP = sorted(SP, key=itemgetter(0))

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

Submission status: Accepted

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

Submission status: Accepted

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

lst.sort()
for (_, _, idx) in lst:
    print(idx)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
h = {}
for i in range(N):
    restaurant, score = list(input().split())
    item = h.get(restaurant, [])
    item.append([int(score), i+1])
    h[restaurant] = sorted(item,key=lambda x: -x[0])

for key in sorted(h.keys()):
    for item in h[key]:
        print(item[1])

Submission status: Accepted

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

res_s = sorted(res, key=lambda x: x[2], reverse=True)    
res_s = sorted(res_s, key=lambda x: x[1], reverse=False)
for x in res_s:
    print(x[0])

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(n):
    a, b = input().split()
    dic += [[a, -int(b), i + 1]]
 
dic.sort()

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

Submission status: Accepted

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

for i in range(n):
    a, b = input().split()
    dic.append([a, -int(b), i + 1])
 
dic.sort()

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

for i in range(n):
    tmp = input().split()
    dic.append([tmp[0], int(tmp[1]), i + 1])
 
dic.sort(key= lambda x: x[1], reverse= True)
dic.sort(key= lambda x: x[0])

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

Submission status: Accepted

Solution code:
n = int(input())
dic = [[x for x in input().split()] for i in range(n)]

for i in range(n):
    dic[i][1] = int(dic[i][1])
    dic[i].append(i + 1)

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

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

Submission status: Accepted

Solution code:
import numpy as np

n = int(input())
num_list = [i for i in range(n)]
city_list = []
point_list = []

for _ in range(n):
  temp = input().split()
  city_list.append(temp[0])
  point_list.append(int(temp[1]))
  
city_set = list(set(city_list))
city_set.sort()

ans=[]
for name in city_set:
  temp = list(filter(lambda x:city_list[x]==name,range(n)))
  temp_num = [num_list[i] for i in temp]
  temp_point = [point_list[i] for i in temp]
  #print(temp_num)
  #print(temp_point)
  while len(temp_num)!=0:
    ans.append(temp_num[np.argmax(temp_point)]+1)
    #print(temp_num[np.argmax(temp_point)])
    del temp_num[np.argmax(temp_point)]
    del temp_point[np.argmax(temp_point)]
for i in ans:
  print(i)

Submission status: Accepted

Solution code:
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

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

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

a.sort(key = lambda x: (x[0],-x[1]))
for i in range(N):
    print(a[i][2]+1)

Submission status: Accepted

Solution code:
n = int(input())
lst = []
for i in range(n):
    l = input().split()
    lst.append([l[0], int(l[1]), i+1])
sorted_lst = sorted(lst, reverse=True)
while sorted_lst != []:
    p = sorted_lst.pop()
    temp = []
    while sorted_lst != [] and p[0] == sorted_lst[-1][0]:
        temp.append(sorted_lst.pop())
    while temp != []:
        print(temp.pop()[2])
    print(p[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))

score = sorted(sp, key=lambda x:(x[0],-x[1]))

for j in range(n):
    print(score[j][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))

SP = sorted(sp)
for j in range(N):
    print(SP[j][2]+1)

Submission status: Accepted

Solution code:
n = int(input())
a = [list(input().split()) for i in range(n)]
d = sorted(set([i[0] for i in a]))
for i in a:
  for j in range(len(d)):
    if i[0] == d[j]:
      i[0] = 10000**(len(d)-(j+1))
c = [i[0]*int(i[1]) if int(i[1]) != 0 else i[0]*0.1 for i in a ]
e = sorted(c,reverse=True)
for i in e:
  print(c.index(i)+1)

Submission status: Accepted

Solution code:
n=int(input())

class Restaurant:
    def __init__(self,number,name,point):
        self.number=number
        self.name=name
        self.point=point
    def __lt__(self,other):
        if self.name<other.name:
            return True
        if self.name==other.name:
            if self.point>other.point:
                return True
        return False
    def __gt__(self,other):
        if self.name>other.name:
            return True
        if self.name==other.name:
            if self.point<other.point:
                return True
        return False
    
    
restaurantlist=[]
number=1
for i in range(n):
    name,point=input().split()
    point=int(point)
    restaurant=Restaurant(number,name,point)
    number+=1
    restaurantlist.append(restaurant)
    
restaurantlist.sort()
for i in restaurantlist:
    print(i.number)

Submission status: Accepted

Solution code:
from functools import cmp_to_key
def cmp(x, y):
  if x[0] < y[0]:
    return -1
  elif x[0] > y[0]:
    return 1
  else:
    return int(y[1]) - int(x[1])
n = int(input())
d = [input().split() for _ in range(n)]
for i in range(n):
  d[i].append(i + 1)
d.sort(key = cmp_to_key(cmp))
for i in range(n):
  print(d[i][2])

Submission status: Accepted

Solution code:
n = int(input().split()[0])

point_list = []

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

sorted_list = sorted(point_list, key=lambda x: (x['city'], -x['point']))

for data in sorted_list:
    print(data['index'])

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.sort(key=lambda x: (x[0], -x[1]))
for _, _, i in SP:
    print(i)

Submission status: Accepted

Solution code:
n = int(input())

graph = {}
for i in range(1, n+1):
    s, p = input().split(' ')
    newMap = {'number': i, 'score': int(p)}
    if s not in graph:
        graph[s] = [newMap]
    else:
        graph[s].append(newMap)

keys = list(graph.keys())
keys.sort()
for key in keys:
    maps = sorted(graph[key], reverse=True, key=lambda x: x['score'])
    for map in maps:
        print(map['number'])

Submission status: Accepted

Solution code:
n = int(input())
x = []
for _ in range(n):
  x.append(input().split())
y = sorted(x)

for i in range(n):
  y[i][1] = 100 - int(y[i][1])
y.sort()
for i in range(n):
  y[i][1] = str(100 - y[i][1])
  print(x.index(y[i])+1)

Submission status: Accepted

Solution code:
n=int(input())

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

for ans in arr:
  print(ans[0])

Submission status: Accepted

Solution code:
import math
import copy

class Score:
    def set_data(self, town, score, idx):
        self.town = set_town
        self.score = set_score
        self.idx = set_idx

inputa = input().split()
# inputb = input().split()

a = int(inputa[0])
# b = int(inputa[1])
# c = int(inputa[2])

# x = int(inputb[0])
# y = int(inputb[1])

# inputList=[]
# for i in range(a):
#     inputNum = input()
#     inputList.append(inputNum)

inputList=[]
for i in range(a):
    inputItem = input().split()
    inputItem.append(i+1)
    inputList.append(inputItem)


# listb = []
# listb = [int(n) for n in inputb]

inputNameListSorted = []
tmp = sorted(inputList, key=lambda x:int(x[1]), reverse = True)
inputNameListSorted = sorted(tmp, key=lambda x:x[0])

for i in range(len(inputNameListSorted)):
    print(inputNameListSorted[i][2])

Submission status: Accepted

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

Submission status: Accepted

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

sp.sort()
for s,p,i in sp:
    print(i)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())

x=list(input().split() for _ in range(n))

for i in range(n):
	x[i][1]=int(x[i][1])
	x[i].append(i)
    
y=sorted(x,key=lambda a:(a[0],-a[1]))

for i in range(n):
	print(y[i][2]+1)

Submission status: Accepted

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

Submission status: Accepted

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


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



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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
tmp = []
ans = []

for i in range(N):
	a, b = input().split()
	tmp.append(list((i + 1, a, int(b))))
	
ans = sorted(tmp, key = lambda x:(x[1], -x[2]))

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

Submission status: Accepted

Solution code:
n = int(input())
data = []
for i in range(n):
    tw, sc = input().split()
    data.append([tw, -int(sc), i+1])

data.sort()

for d in data:
    print (d[2])

Submission status: Accepted

Solution code:
n = int(input())
ll = []
for i in range(n):
	s, p = list(input().split())
	ll.append((s,-int(p),i+1))
ll1 = sorted(ll, key = lambda x:x[1])
ll2 = sorted(ll1, key = lambda x:x[0])

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

Submission status: Accepted

Solution code:
N=int(input())

spn=[[(s,-int(p)) for s,p in[input().split()]]+[i+1] for i in range(N)]
spn.sort()
#print(spn)
for a,b in spn:
	print(b)

Submission status: Accepted

Solution code:
n = int(input())
d = {}
for idx in range(n):
    i = input().split()
    m = i[0]
    s = int(i[1])
    if m in d:
        d[i[0]].append((s, idx+1))
    else:
        d[i[0]] = [(s, idx+1)]

for k in sorted(d.keys()):
    for i in sorted(d[k], reverse=True):
        print(i[1])

Submission status: Accepted

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

Submission status: Accepted

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

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

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

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