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:
#テストファイルで実行する時
import sys
if sys.platform =='ios':
    sys.stdin=open('input_file.txt')

n = int(input())

l = [list(map(str,input().split())) for i in range(n) ]

for i in range(n):
	l[i].insert(0,i+1)
	
for i in range(n):
	l[i][2] = int(l[i][2])
	

#2次元リストの中の特定の列で並び替える(降順)
l.sort(key=lambda x: x[2], reverse=True )
#print(l)

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

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

Submission status: Accepted

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

for t in T:
    print(t[2])

Submission status: Accepted

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


li.sort()
for i in range(n):
    print(li[i][2])

Submission status: Accepted

Solution code:
import copy
n=int(input())
alis=[]
for i in range(n):
	a,b=map(str,input().split())
	alis.append([a,int(b)])
blis=copy.copy(alis)
blis.sort(key=lambda blis:(blis[0],-blis[1]))
for i in blis:
	print(alis.index(i)+1)

Submission status: Accepted

Solution code:

from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
#import random


def I(): return int(input())
def MI(): return map(int, input().split())
def MS(): return map(str, input().split())
def LI(): return [int(i) for i in input().split()]
def LI_(): return [int(i)-1 for i in input().split()]
def StoI(): return [ord(i)-97 for i in input()]
def ItoS(nn): return chr(nn+97)
def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


# show_flg = False
show_flg = True


def main():
    N = I()
    restrants = [None] * N

    for i in range(N):
        S, P = MS()
        restrants[i] = (S, int(P), i+1)

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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:

N = int(raw_input())
Restaurant = {}
for i in xrange(N):
    city, score  = raw_input().split()
    if city in Restaurant.keys():
        Restaurant[city].append((int(score), i+1))
    else:
        Restaurant[city] = [(int(score), i+1)]

city_sort = sorted(Restaurant.keys())
for city in city_sort:
    score_sort = sorted(Restaurant[city], key=lambda x:x[0], reverse=True)
    for score in score_sort:
        print score[1]

Submission status: Accepted

Solution code:
N = int(input())
SPn =[]
for i in range(N):
    SP = input().split(' ')
    S = SP[0]
    P = int(SP[1])
    SPn.append([S,P,i+1])
SPn.sort()
first_val = SPn[0][0]
current_list = [SPn[0]]
for i in range(1,N):
    if first_val == SPn[i][0]:
        current_list.append(SPn[i])
    else:
        current_list.sort(key=lambda x:(x[1]), reverse=True)
        for val in current_list:
            print(val[2])
        current_list = [SPn[i]]
        first_val = SPn[i][0]
current_list.sort(key=lambda x:(x[1]), reverse=True)
for val in current_list:
    print(val[2])

Submission status: Accepted

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

for j in x_new:
  print(j[0])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
import numpy as np
def print_ans(N, ar):
    """Test Case
    >>> print_ans(6,[["khabarovsk",-20, 1], ["moscow",-10, 2], ["kazan",-50, 3], ["kazan",-35, 4], ["moscow",-60, 5], ["khabarovsk",-40, 6]])
    3
    4
    6
    1
    5
    2
    >>> print_ans(10, [["yakutsk", -10, 1 ], ["yakutsk", -20, 2 ], ["yakutsk", -30, 3 ], ["yakutsk", -40, 4 ], ["yakutsk", -50, 5 ], ["yakutsk", -60, 6 ], ["yakutsk", -70, 7 ], ["yakutsk", -80, 8 ], ["yakutsk", -90, 9 ], ["yakutsk", -100,10]])
    10
    9
    8
    7
    6
    5
    4
    3
    2
    1
    """
    ans = sorted(ar)
    for a in ans:
        print(a[2])

if __name__ == '__main__':
    N = int(input().rstrip())
    ar = []
    for i in range(N):
        s, p = input().rstrip().split()
        p = int(p)
        ar.append([s, -p, i + 1])
    print_ans(N, ar)

Submission status: Accepted

Solution code:
n = int(input())
def int_or_st(i):
  if str.isnumeric(i):
    return int(i)
  else:
    return i
res = [list(map(int_or_st,input().split())) for _ in range(n)]
sorted_res = sorted(res,reverse=True,key=lambda x:x[1])
sorted_res.sort(key=lambda x:x[0])
for i in sorted_res:
  print(res.index(i)+1)

Submission status: Accepted

Solution code:

N = int(input())

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

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

for order,_,__ in order_city_point:
    print(order)

Submission status: Accepted

Solution code:
n = int(input())

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

li = sorted(li, key=lambda x:(x[0], -x[1]))
#print(li)
for i in range(n):
    print(li[i][2])

Submission status: Accepted

Solution code:
n = int(input())

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

li.sort()
for i in range(n):
    print(li[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].append(i+1)
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())
SPlist = []
for i in range(N):
    buff  = input().split()
    SPlist.append([i+1,str(buff[0]),int(buff[1])])
SPlist = sorted(SPlist,key = lambda x:x[2],reverse=True)
SPlist = sorted(SPlist,key=lambda x:x[1])
[print(i[0]) for i in SPlist]

Submission status: Accepted

Solution code:
N=int(input())
X=[]
for i in range(N):
  S,P =map(str,input().split())
  X +=[[S,100-int(P),i+1]]
X=sorted(X)
for j in range(N):
  print(X[j][2])

Submission status: Accepted

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

Submission status: Accepted

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

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

items = list(SP.items())
items.sort()
for _, A in items:
    A.sort(reverse=True)
    for _, i in A:
        print(i)

Submission status: Accepted

Solution code:
n = int(input())

data = [["",0,0] for i in range(n)]

for i in range(n):
  data[i][0], data[i][1] = input().split()
  data[i][1] = int(data[i][1])
  data[i][2] = i+1

#print(data)

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

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

Submission status: Accepted

Solution code:
# ABC 128: B – Guidebook
from operator import itemgetter

n = int(input())

s = []
p = []

for _ in range(n):
    tmp = [s for s in input().split()]
    s.append(tmp[0])
    p.append(int(tmp[1]))

restaurants = []
for i in range(n):
    restaurants.append([i + 1, s[i], p[i]])

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

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

Submission status: Accepted

Solution code:
N=int(input())
d=[]
if N>0:
  for i in range(N):
    city,score=input().split(" ")
    score=int(score)
    d.append([i+1,city,score])

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

Submission status: Accepted

Solution code:
n = int(input())
s = [0]*n
p = [0]*n
l = [[] for i in range(n)]

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

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

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

Submission status: Accepted

Solution code:
n = int(input())

book = []

for i in range(n):
    line = input().split()
    name = line[0]
    score = int(line[1])
    number = i+1
    list = [name,score,number]
    book.append(list)

#sort
'''
book.sort(key=lambda x: x[n])でソート
-マイナス指定している・・・
'''
book.sort(key=lambda x: (x[0], -x[1]))
print("")
[print(item[2]) for item in book]

Submission status: Accepted

Solution code:
n = int(input())
li = []
for i in range(n):
    a = input()
    a, b = a.split()
    b = int(b)
    c = i+1
    li.append([a, b, c])

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

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

Submission status: Accepted

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

for i, sp in enumerate(SP):
    sp[1] = int(sp[1])
    sp.append(i+1)

SP.sort(key=lambda x: (x[0], -x[1]))
for sp in SP:
    print(sp[2])

Submission status: Accepted

Solution code:
import unittest


class TestB(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think([
                ['khabarovsk' ,20],
                ['moscow', 10],
                ['kazan', 50],
                ['kazan', 35],
                ['moscow', 60],
                ['khabarovsk', 40]
            ]),
                [3, 4, 6, 1, 5, 2]
        )

    def test_2(self):
        self.assertEqual(think([
                ['yakutsk', 10],
                ['yakutsk', 20],
                ['yakutsk', 30],
                ['yakutsk', 40],
                ['yakutsk', 50],
                ['yakutsk', 60],
                ['yakutsk', 70],
                ['yakutsk', 80],
                ['yakutsk', 90],
                ['yakutsk', 100]
            ]),
                [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
        )


def solve():
    list_of_s_and_p = read()
    result = think(list_of_s_and_p)
    write(result)


def read():
    n = read_int(1)[0]
    list_of_s_and_p = []
    for _ in range(n):
        buf = read_line().split()
        list_of_s_and_p.append([buf[0], int(buf[1])])
    return list_of_s_and_p


def read_int(n):
    return read_type(int, n)


def read_float(n):
    return read_type(float, n)


def read_type(t, n):
    return list(map(lambda x: t(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(list_of_s_and_p):
    data_with_index = []
    for i, e in enumerate(list_of_s_and_p):
        data_with_index.append((i + 1, e[0], e[1]))
    data_with_index.sort(key=lambda x: (x[1], -x[2]))
    return [x[0] for x in data_with_index]


def write(result):
    for r in result:
        print(r)


if __name__ == '__main__':
    # unittest.main()
    solve()

Submission status: Accepted

Solution code:
N = int(input())
A = [input().split() for _ in range(N)]
a = []
for i in range(N):
  a.append([A[i][0], 100 - int(A[i][1])])
A = sorted(a)

for i in range(N):
  print(a.index(A[i])+1)

Submission status: Accepted

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

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

for j in range(N):
  print(arr[j][2])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
N = int(input())
S = list()
P = list()
SP = list()
for n in range(N):
    s, p = input().split()
    SP.append([s, -int(p), n+1])
SP.sort()
for s,p,i in SP:
    print(i)

Submission status: Accepted

Solution code:
# 2019-11-13 21:06:16(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    n = int(sys.stdin.readline().rstrip())
    
    order = []
    cities = []
    for i in range(1, n+1):
        city, score = sys.stdin.readline().split()
        order.append([city, int(score), i])
        cities.append(city)

    res = dict((c, list()) for c in set(cities))
    for i in range(n):
        res[order[i][0]].append(order[i][1:])

    for city, score in sorted(res.items()):
        for s in sorted(score, reverse=True):
            print(s[1])

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input().strip())
r = [[0] * 2] * n

for i in range(n):
    r[i] = list(map(lambda x: x.strip(), input().split()))

for i in range(n):
    r[i].extend([i + 1])

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import numpy as np
sys.setrecursionlimit(10**9)
def input():
    return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    SP=['']*N
    for i in range(N):
        S,P=input().split()
        SP[i]=S+str((100-int(P))).zfill(3)
    SP_argsort=np.argsort(SP)
    for i in SP_argsort:
        print(i+1)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a=int(input())
c=[input().split(" ")for i in range(0,a)]
for i in c:
    i[1]=int(i[1])
#print(c)
d=sorted(c,key=lambda x:(x[0],-x[1]))
#print(d)
for j in d:
    print(c.index(j)+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
L = []
for _ in range(n):
    s, p = input().split()
    p = int(p)
    L.append([s, p, _ + 1])
# print(L)


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

Submission status: Accepted

Solution code:
n = int(input())

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

for s,p,n in sorted(spl):
    print(n+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from operator import itemgetter
n=int(input())
li=[]
for i in range(n):
  temp=input().split()
  li.append({"city":temp[0],"point":-int(temp[1]),"ind":i+1})
ans=sorted(li,key=itemgetter("city","point"))
#print(ans)
for dic in ans:
  print(dic["ind"])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
l = []
for i in range(N):
  l.append(list(map(str, input().split())))

for i in range(N):
  l[i][1] = int(l[i][1])
  l[i].append(i+1)
  l[i][1] = 100-l[i][1]
  
l.sort()

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

Submission status: Accepted

Solution code:
import numpy as np
rest = {}
N = int(input())
for i in range(N):
    s,p = input().split()
    if(s not in rest.keys()):
        rest[s] = [[int(p)],[i+1]]
    else:
        rest[s][0].append(int(p))
        rest[s][1].append(i+1)

sort_rest = sorted(rest.keys())
for r in sort_rest:
    argsort_ = np.argsort(np.array(rest[r][0]))[::-1]
    for i in argsort_:
        
        #pdb.set_trace()
        print(rest[r][1][i])

Submission status: Accepted

Solution code:
N = int(input())
dic ={}

for i in range(N):
    line = input().split()
    dic[i] = [line[0], int(line[1])]


ans = []
for index, i in enumerate(sorted(dic.items(), key= lambda x: (x[1][0],-x[1][1]))):
    ans.append([i])

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

Submission status: Accepted

Solution code:
n = int(input())

place = {}
for i in range(n):
  tmp = input().split()
  s = tmp[0]
  k = int(tmp[1])
  pt = (k, i)
  if s in place:
    place[s].append(pt)
  else:
    place[s] = [pt]

placek = sorted(place)

for i in placek:
  pts = sorted(place[i], reverse=True)
  for pt in pts:
    print(pt[1] + 1)

Submission status: Accepted

Solution code:
N = int(input())
SP = {}
for i in range(N):
    line = input().split()
    SP[i] = [line[0], int(line[1])]
    
ans = []
for i, index in enumerate(sorted(SP.items(), key= lambda x: (x[1][0], -x[1][1]))):
    ans.append([index, i])

for ls in ans:
    print(ls[0][0] + 1)

Submission status: Accepted

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

from operator import itemgetter, attrgetter

N = int(input())
#S = [0] * N
#P = [0] * N
score_chart = []
for i in range(N):
    array = list(input().strip().split())
    array.append(i+1)
    score_chart.append(array)
for i in range(N):
    score_chart[i][1] = int(score_chart[i][1])
s = sorted(score_chart, key=itemgetter(1),reverse=True)
s = sorted(s, key=itemgetter(0))

#print(score_chart)
for i in range(N):
    print(s[i][2])

Submission status: Accepted

Solution code:
#%%
import sys
def input():
    return sys.stdin.readline().rstrip()

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

# %%
if __name__ == '__main__':
    main()

# %%
# from atcoder_test import doTest
# doTest("abc128","b",main)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

dic = []
S, P = [], []
for i in range(N):
    _s, _ = [x for x in input().split()]
    _p = int(_)
    S.append(_s)
    P.append(_p)
    dic.append((_s, -_p, i+1))

dic.sort()

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(N):
    name, point = input().split()
    data.append((name, int(point), i))

data.sort(key=lambda x:-x[1])
data.sort(key=lambda x:x[0])
for d in data:
    print(d[2] + 1)

Submission status: Accepted

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

for i in range(N):
    name, point = input().split()
    data.append((name, int(point), i))

data.sort(key=lambda x:(x[0], -x[1]))
for d in data:
    print(d[2] + 1)

Submission status: Accepted

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

S = sorted(S, key=lambda x: (x[0], -1 * int(x[1])), reverse=False)

for s in S:
    print(s[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 l in ls:
    print(l[2])

Submission status: Accepted

Solution code:
n=int(input())

li=[]

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


new_li=sorted(li,key=lambda x:x[2] , reverse=True)
new2_li=sorted(new_li,key=lambda x:x[1])


for j in range(0,n):
  print(new2_li[j][0])

Submission status: Accepted

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

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

X.sort()

for i in range(0,N-1):
    for j in range(i+1,N):
        if X[i][0]==X[j][0]:
            if X[i][1]<X[j][1]:
                tmp=X[i]
                X[i]=X[j]
                X[j]=tmp

for i in range(0,N):
    print(X[i][2])

Submission status: Accepted

Solution code:
n = int(input())
dct_id = {}
dct_city = {}
cities = []
for i in range(n):
  tmp = input()
  city = tmp.split()[0]
  score = int(tmp.split()[1])
  dct_id[score] = i+1
  #print(city, score)
  if city not in dct_city.keys():
    dct_city[city] = [score]
  else:
    dct_city[city].append(score)
  cities.append(city)
cities = list(set(cities))
cities.sort()
#print(cities)
for city in cities:
  #print(city)
  score_list = dct_city[city]
  score_list.sort(reverse=True)
  #print(score_list)
  for score in score_list:
    print(dct_id[score])
    #print(city,score,dct_id[score])

Submission status: Accepted

Solution code:
# AC128 B - Guidebook
# 2019/11/1

N, *SP = [s.split() for s in open(0)]
SP = {(s[0], int(s[1])):index for index, s in enumerate(SP)}
# print(N, SP)
SP_values = list(SP.keys())
# print(SP_values)
# sorted(SP_values, key=lambda x:(x.values[0], -x.values[1]))
SP_values.sort(key=lambda x:(x[0], -x[1]))
# print(SP_values)

for i in SP_values:
    print(int(SP[i])+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
d=[]
ans=[[]for i in range(n)]
for i in range(n):
  d.append(list(input().split()))
for i in range(n):
  ans[i].append(d[i][0])
  j=int(d[i][1])
  ans[i].append(-j)
  ans[i].append(i)
ans.sort()

for i in range(n):
  print(ans[i][2]+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 range(N):
  print(l[i][2])

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000)
INF = 1<<32


def solve(N: int, S: "List[str]", P: "List[int]"):
    sp = [[i, S[i], P[i]] for i in range(N)]

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

    for i in range(N):
        print(sp[i][0]+1)
    return



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:
n = int(input())
s = [input().split() for i in range(n)]

for j in range(n):
  s[j].append(j+1)

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

for k in range(n):
  print(num[k][2])

Submission status: Accepted

Solution code:
N = int(input())

dat = []

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

dat.sort()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from operator import itemgetter
from operator import attrgetter
N = int(input())
SP = []
for i in range(N):
  s, p = input().split()
  SP.append({"index":i, "S":s, "P":-int(p)})
SP = sorted(SP, key = itemgetter("S", "P"))
for i in range(N):
  print("{}".format(SP[i]["index"]+1))

Submission status: Accepted

Solution code:
N = int(input())
S = [0] * N
P = [0] * N
restaurant= []
for i in range(N):
  S[i], P[i] = input().split()

for i in range(N):
  restaurant.append([i+1, S[i], int(P[i])])

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

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

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
SP = []
for idx in range(N):
	tmp = input().split()
	tmp[1] = int(tmp[1])
	tmp.append(idx+1)
	SP.append(tmp)

sorted_items = sorted(
  SP,
  key = lambda sp: (sp[0], -1 * sp[1])
)
for item in sorted_items:
	print(item[2])

Submission status: Accepted

Solution code:
N = int(input())
l = [input().split() for _ in range(N)]
a = [[x[0], -int(x[1])] for x in l]

ans = sorted(a)

for i in range(N):
    print(a.index(ans[i]) + 1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
s = sorted([[x for x in input().split()] + [i+1,] for i in range(n)], key=lambda x: x[0]+chr(100-int(x[1])))
for city, score, i in s:
  print(i)

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(n):
    score_list.append(list(input().split() +[str(i+1)]))
    score_list[i][1] = 100 - int(score_list[i][1])
score_list.sort()
for i in range(n):
    print(score_list[i][2])

Submission status: Accepted

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

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

ANS= sorted(ANS,reverse=True, key=lambda x: x[2])
ANS= sorted(ANS, key=lambda x: x[1])

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

Submission status: Accepted

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

for i in range(n):
    list1.append(list(input().split() + [str(i+1)]))
    list1[i][1] = 100 - int(list1[i][1])

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

Submission status: Accepted

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

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

X.sort()

for i in range(0,N-1):
    for j in range(i+1,N):
        if X[i][0]==X[j][0]:
            if X[i][1]<X[j][1]:
                tmp=X[i]
                X[i]=X[j]
                X[j]=tmp

for i in range(0,N):
    print(X[i][2])

Submission status: Accepted

Solution code:
n  = int(input())

w_list = [[0]*n]*n

for i in range(n):
  w_list[i] = input().split()
  w_list[i].append(i+1)
  
w_list.sort(key = lambda l: (l[0], -int(l[1])))
print(*[w[-1] for w in w_list], sep  = '\n')

Submission status: Accepted

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

for i in range(0,N):
  L[i][1] = 100-int(L[i][1])
  L[i].append(i+1)
L.sort()

#print(L)

for j in range(0,N):
  print(L[j][2])

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
# S昇順かつP降順
n = int(input())
lis = []
for i in range(1, n+1):
    a, b = input().split()
    lis.append((i, a, int(b)))

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(N):
    L[i].append(i+1)
    
for _ in range(N):
    idx = 0
    temp = L[0]
    ans = 0
    while idx < len(L):
        if temp[0] > L[idx][0]:
            ans = idx
            temp = L[idx]
        elif temp[0] == L[idx][0] and int(temp[1]) < int(L[idx][1]):
            ans = idx
            temp = L[idx]
        idx += 1
    ans_list = L.pop(ans)
    print(ans_list[2])