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

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
guide = []
for i in range(N):
    s,p=LS()
    guide.append([s,100-int(p),i+1])
guide.sort()
for a in guide:
    print(a[2])

Submission status: Accepted

Solution code:
N = int(input())

L = []

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

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])
list.sort(L)
for i in range(n):
  print(L[i][2])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#import operator
n = int(input())
l = set()
cnt = 1
d = {}
o = {}
for i in range(n):
    s,p = input().split()
    p = int(p)
    d[(s, p)] = cnt
    if s in o:
        x = o[s]
        x.append(p)
        o[s] = x

    else:
        o[s] = [p]

    l.add(s)
    cnt = cnt+1

w = list(l)
w.sort()
k = []
#print("  ")
for i in w:
    m = o[i]
    m.sort(reverse = True)
    for j in m:
        #print(i,j,d[(i,j)])
        k.append(d[(i,j)])

for h in k:
    print(h)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

    restaurants.append([S,-P, i+1])

restaurants.sort()

for x in restaurants:
    print(x[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:
n=[[i+1,input().split()] for i in range(int(input()))]
[print(i[0]) for i in sorted(n,key=lambda x:(x[1][0],-int(x[1][1])))]

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

spl = {}
spl = []
for i in range(n):
    s,p = map(str, input().split())
    p = int(p)
    spl.append((s,p*(-1),i+1))
    # spl.setdefault(s,[])
    # spl[s].append((p,i+1))

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

# spl = sorted(spl.items(), key=lambda x:x[0])
# for s, pil in spl:
#     pil.sort()
#     for p,i in pil:
#         print(i)

Submission status: Accepted

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
ans = []
for i in range(n):
    name,score = input().split()
    score = int(score)
    ans.append([name,score,i+1])
ans = sorted(ans,key = lambda x:x[1],reverse = True)
ans = sorted(ans,key = lambda x:x[0])
for i in range(n):
    print(ans[i][2])

Submission status: Accepted

Solution code:
n = int(input())
spi = sorted([list(input().split())+[i+1] for i in range(n)])
ans = []
before = ""
for s,p,i in spi:
    if ans == []:
        ans = [[int(p),i]]
        before = s
    else:
        if before == s:
            ans.append([int(p),i])
        else:
            for j in sorted(ans)[::-1]: print(j[1])
            ans = [[int(p),i]]
            before = s
if ans:
    for i in sorted(ans)[::-1]: print(i[1])

Submission status: Accepted

Solution code:
N = int(input())
A = [list(input().split()) for _ in range(N)]
A = sorted([(A[i][0],int(A[i][1]),i+1) for i in range(N)],key=lambda x:x[1],reverse=True)
A = sorted(A,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())
    p = int(p)
    SP.append((s, p, i+1))
SP.sort(key=lambda x: (x[0], -x[1]))
for s, p, j in SP:
    print(j)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))


n = ini()
res = []
for i in range(n):
    s, p = ins().split()
    p = int(p)
    res.append((s, -p, i))
res.sort()


def solve():
    return [i + 1 for s, p, i in res]


print(*solve(), sep="\n")

Submission status: Accepted

Solution code:
N=int(input())
d={}
k=[]
for x in range(N):
  S,P=input().split()
  if S not in k:
    k.append(S)
    d[S]=[]
  d[S].append([int(P),x+1])
k.sort()
for y in k:
  d[y].sort(reverse=True)
  for z in range(len(d[y])):
    print(d[y][z][1])

Submission status: Accepted

Solution code:
# abc128_b.py
# https://atcoder.jp/contests/abc128/tasks/abc128_b

# B - Guidebook /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 200点

# 問題文
# あなたは美味しいレストランを紹介する本を書くことにしました。 
# あなたは N個のレストラン、レストラン 1、レストラン 2、…、レストラン N を紹介しようとしています。
# レストラン i は Si 市にあり、あなたは 100 点満点中 Pi 点と評価しています。 
# 異なる 2個のレストランに同じ点数がついていることはありません。
# この本では、次のような順でレストランを紹介しようとしています。
#     市名が辞書順で早いものから紹介していく。
#     同じ市に複数レストランがある場合は、点数が高いものから紹介していく。
# この本で紹介される順にレストランの番号を出力してください。

# 制約
#     1≤N≤100
#     Sは英小文字のみからなる長さ 1 以上 10以下の文字列
#     0≤Pi≤100
#     Piは整数
#     Pi≠Pj(1≤i<j≤N)

# 入力
# 入力は以下の形式で標準入力から与えられる。
# N
# S1 P1
# :
# SN PN

# 出力
# N行出力せよ。i 行目 (1≤i≤N) には、i番目に紹介されるレストランの番号を出力せよ。

# 入力例 1
# 6
# khabarovsk 20
# moscow 10
# kazan 50
# kazan 35
# moscow 60
# khabarovsk 40

# 出力例 1
# 3
# 4
# 6
# 1
# 5
# 2

# 3種類の市名は辞書順で kazan < khabarovsk < moscow です。 
# それぞれの市について、点数が高いレストランから順に紹介されていきます。
# よって、レストランは 3,4,6,1,5,2の順に紹介されていきます。

# 入力例 2
# 10
# yakutsk 10
# yakutsk 20
# yakutsk 30
# yakutsk 40
# yakutsk 50
# yakutsk 60
# yakutsk 70
# yakutsk 80
# yakutsk 90
# yakutsk 100

# 出力例 2
# 10
# 9
# 8
# 7
# 6
# 5
# 4
# 3
# 2
# 1


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    # S = lines[0]
    N = int(lines[0])
    # A, P = list(map(int, lines[0].split()))
    # values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    tmps1 = list()
    tmps2 = list()
    for i in range(1, N+1):
        s, p = lines[i].split()
        # 整形
        tmp = (s+(' ')*10)[:11] + str(200-int(p))
        tmps1.append(tmp)
        tmps2.append(tmp)
    tmps1.sort()

    results = list()
    for tmp1 in tmps1:
        for i in range(N):
            if tmps2[i] == tmp1:
                results.append(i+1)

    return results


# 引数を取得
def get_input_lines():
    line = input()
    N = int(line)
    lines = list()
    lines.append(line)
    for _ in range(N):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['6', 'khabarovsk 20', 'moscow 10', 'kazan 50', 'kazan 35', 'moscow 60', 'khabarovsk 40']
        lines_export = [3, 4, 6, 1, 5, 2]
    if pattern == 2:
        lines_input = ['10', 'yakutsk 10', 'yakutsk 20', 'yakutsk 30', 'yakutsk 40', 'yakutsk 50', 'yakutsk 60', 'yakutsk 70', 'yakutsk 80', 'yakutsk 90', 'yakutsk 100']
        lines_export = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines()
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
n = int(input())
list = []
for xi in range(n):
    add1, add2 = input().split()
    add = [int(add2), add1, xi+1]
    list.append(add)
list.sort(key=lambda list2: list2[1])


name = list[0][1]
list2 = [list[0]]
count = 1
for xi in range(1,n):
    if name == list[xi][1]:
        list2.append(list[xi])
        count += 1
    else:
        list2.sort()
        for yi in range(count-1,-1,-1):
            print(list2[yi][2])
        name = list[xi][1]
        list2 = [list[xi]]
        count = 1

if len(list2)<n:
    list2.sort()
for yi in range(count-1,-1,-1):
    print(list2[yi][2])
name = list[xi][1]
list2 = [list[xi]]
count = 1

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import copy

N = int(input())
org_arr = [list(input().split()) for _ in range(N)]
for i in range(len(org_arr)):
    org_arr[i][1]=int(org_arr[i][1])
    org_arr[i].append(i+1)

arr = copy.copy(org_arr)


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

for i in range(len(arr)):
    arr[i].append(i+1)

arr.sort(key=lambda x:x[0])
for i in range(len(arr)):
    print(arr[i][2])

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from operator import itemgetter
N = int(input())

T = list()
for i in range(N):
    S, P = map(str, input().split())
    T.append((S, int(P), str(i+1)))

T = sorted(T, key=itemgetter(1), reverse=True)
T = sorted(T, key=itemgetter(0))
for t in T:
    print(t[2])

Submission status: Accepted

Solution code:
n = int(input())

l = []

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

l.sort()

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

Submission status: Accepted

Solution code:
N = int(input())
List = []
for i in range(N):
  List.append(list(map(str, input().split())))
Names = []
Points = []
for i in range(N):
  Names.append(List[i][0])
  Points.append(int(List[i][1]))
slName = set(Names)
NewName = list(slName)
NewName.sort()
Points.sort(reverse = True)
for i in range(len(NewName)):
  for j in range(len(Points)):
    for k in range(N):
      if List[k][0] == NewName[i] and int(List[k][1]) == Points[j]:
        print(k+1)
      else:
        pass

Submission status: Accepted

Solution code:
# リストに格納する
l = []
lk = []
lv = []
n = int(input())
for _ in range(n):
    s, p = input().split()
    l.append(f"{s} {p}")
    lk.append(s)
    lv.append(int(p))


# リストを辞書に変換する
d = {}
for i in range(n):
    s, p = lk[i], lv[i]
    if s in d:
        d[s].append(p)
    else:
        d[s] = []
        d[s].append(p)


# 辞書をソートする・答えを出力する
d = dict(sorted(d.items()))
for k, v in d.items():
    d[k] = sorted(v, reverse=True)
    for i in d[k]:
        print(l.index(f"{k} {i}") + 1)

Submission status: Accepted

Solution code:
def main():
  n = int(input())
  xy = [map(str, input().split()) for _ in range(n)]
  x, y = [list(i) for i in zip(*xy)]
  ans_list=list(range(0,n))
  for i in range(0,n):
    min=i
    for j in range(i+1,n):
      if x[ans_list[min]]>x[ans_list[j]] or (x[ans_list[min]]==x[ans_list[j]] and int(y[ans_list[min]])<int(y[ans_list[j]])):
        min=j
    
    if ans_list[min]!=ans_list[i]:
      tmp=ans_list[i]
      ans_list[i]=ans_list[min]
      ans_list[min]=tmp
    print(ans_list[i]+1)
  
main()

Submission status: Accepted

Solution code:
n = int(input())
s = []
p = [0] * 101
d = {}
for i in range(n):
    a,b = input().split()
    b = int(b)
    s.append(a)
    p[b] = i+1
    if a in list(d.keys()):
        d[a].append(b)
        continue
    d[a] = [b]
s = sorted(set(s))
for i in s:
    c = sorted(d[i],reverse=True)
    for j in c:
        print(p[j])

Submission status: Accepted

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

for n in range(N):
  s,p = input().split()
  R.append((s,-int(p),n+1))
  
for s,p,n in sorted(R):
  print(n)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    l = []
    d = {}
    for i in range(n):
        s,p = input().split()
        if s not in l:
            l.append(s)
            d[s] = []
        d[s].append([int(p), i+1])
    
    for i in sorted(l):
        for j in sorted(d[i], reverse=True):
            print(j[1])
main()

Submission status: Accepted

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

for i in range(N):
    SP[i][1] = int(SP[i][1])

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

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

Submission status: Accepted

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

for i in sorted(l):
  for j in sorted(d[i], reverse=True):
    print(j[1])

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 = sorted(s,key=lambda x:int(x[1]),reverse=True)
s = sorted(s,key=lambda x:x[0])
for i in range(n):
    print(s[i][2])

Submission status: Accepted

Solution code:
import sys
from collections import deque


def input():
    return sys.stdin.readline().rstrip()


def main():
    N =int(input())
    l=[]
    for i in range(N):
        k,s = input().split()
        s = int(s)
        l.append([k,s,i+1])



    l.sort(reverse=True)
    mem =""
    q=[]
    for i in range(N):
        k,s,j = l.pop()
        if mem ==k:
            q.append([s,j])
            mem =k
        else:
            q.sort(reverse=True)
            for o,p in q:
                print(p)
            q=[]
            q.append([s, j])
            mem =k
    q.sort(reverse=True)
    if q:
        for o, p in q:
            print(p)






if __name__ == "__main__":
    main()

Submission status: Accepted

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

for i in range(1,n+1):
    l[i-1].append(i)
#print(l)

for i in range(n):
    l[i][1] = (int(l[i][1]))*(-1)
#print(sorted(l))
sl = sorted(l)

#ans = sorted(l.sort(),reverse = True, key = lambda x:x[1])
#print(ans)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from operator import itemgetter

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

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

Submission status: Accepted

Solution code:
N = int(input())
L = sorted([list(input().split()) + [i + 1] for i in range(N)], key = lambda x: x[0])
while len(L) > 0:
    c = sum([x[0] == L[0][0] for x in L])
    M = sorted(L[0: c], key = lambda x : int(x[1]), reverse = True)
    for x in M:
        print(x[2])
    L = L[c:]

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
r = []
for i in range(n):
    s, p = input().split()
    r.append((i + 1, s, int(p)))
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:
n = int(input())
li = []
for i in range(n):
    a,b = input().split()
    li.append([i+1,a,int(b)])
lia = sorted(li, key = lambda x:(x[1],-x[2]))
for i in range(n):
    print(lia[i][0])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':

	n = int(input())

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

	B = sorted(A,key=lambda x:(x[1],-x[2]))
	for j in B:
		print(j[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+1])
sp.sort(key=lambda x : (x[0], -x[1]))
for x in sp:
    print(x[2])

Submission status: Accepted

Solution code:
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

N = ri()
SP = []
for i in range(N):
	s =rs()
	S, P = s.split(' ')
	P = int(P)
	SP.append((S, -P, i+1))

SP.sort()
for s, p, n in SP:
	print(n)

Submission status: Accepted

Solution code:
(N,),*sp = [s.split() for s in open(0)]

sp = [(s,-int(p),i+1) for i,(s,p) in enumerate(sp)]

for _,_,i in sorted(sp):
    print(i)

Submission status: Accepted

Solution code:
n = int(input())
l = []
for i in range(n):
    s,p = map(str,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())

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

l.sort()
for i in l:
  print(i[-1])

Submission status: Accepted

Solution code:
n=int(input())

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

l.sort()
for i in l:
  print(i[-1])

Submission status: Accepted

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

n = int(input())

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

    shop += [{'idx': i+1, 'val':s+f'{100-p:03}'}]

shop_sorted = sorted(shop, key=lambda x:x['val'])

for shop in shop_sorted:
    print(shop['idx'])

Submission status: Accepted

Solution code:
n = int(input())
sp = [list(map(str, input().split())) for i in range(n)]
for i in range(n):
  sp[i][1] = int(sp[i][1]) * -1
x = sorted(sp)
for i in range(n):
  print(sp.index(x[i])+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())
l = []
for i in range(N):
    s,p = input().split(" ")
    l.append([s,-int(p),i+1])
l.sort()

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

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()
for s,p,i in sp:
    print(i)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
d = {}
for i in range(n):
  s,p = input().split()
  if d.get(s,-1)==-1:
    d[s] = {int(p):i+1}
  else:
    d[s][int(p)] = i+1
d = sorted(d.items(), key=lambda x:x[0])
for k in d:
  l = sorted(k[1].items(), key=lambda x:x[0])[::-1]
  for t in l:
    print(t[1])

Submission status: Accepted

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

s1 = sorted(s,key = lambda S:S[1],reverse=True)
s2 = sorted(s1,key = lambda S:S[0])
for i in range(n):
  print(s2[i][2])

Submission status: Accepted

Solution code:
import operator as op

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

s1 = sorted(s,key = op.itemgetter(1),reverse=True)
s2 = sorted(s1,key = op.itemgetter(0))
for i in range(n):
  print(s2[i][2])

Submission status: Accepted

Solution code:
N=int(input())
ls1=[]
for i in range(N):
    si,pi=input().split()
    pi2=int(pi)
    ls2=[si,pi2,i+1]
    ls1.append(ls2)
ls1.sort(key=lambda x:-x[1])   
ls1.sort(key=lambda x:x[0])
for i in range(N):
    print(ls1[i][2])

Submission status: Accepted

Solution code:
N = int(input())

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

# sortはstable。レコードの中に同じキーがある場合、もともとの順序が維持される
sorted_NSP = sorted(NSP, key=lambda x: x[2], reverse=True)
sorted_NSP = sorted(sorted_NSP, key=lambda x:x[1]) 
for nsp in sorted_NSP:
    print(nsp[0])

Submission status: Accepted

Solution code:
import sys
N = int(input())
test = lambda x: [ x[0],int(x[1]) ]
array = [ [test(input().split()),int(x+1)] for x in range(N) ]

if not ( 1 <= N <= 100 ): sys.exit()
for I in array:
    if not ( 1 <= len(I[0][0]) <= 10 ): sys.exit()
    if not I[0][0].islower(): sys.exit()
    if not ( 0 <= I[0][1] <= 100 ): sys.exit()
    if not isinstance(I[0][1],int): sys.exit()

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

for I in array:
    print(I[1])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# unihernandez22
# https://atcoder.jp/contests/abc128/tasks/abc128_b
# implementation

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

for i in range(1, n+1):
    name, score = input().split()
    restaurants.append((name, -int(score), i))

restaurants.sort()
for i in restaurants:
    print(i[2])

Submission status: Accepted

Solution code:
n = int(input())
d = {}
for i in range(n):
    s ,p = input().split()
    p = int(p)
    if not(s in d):
        d[s] = {}
    d[s][p*-1] = i+1
for i in sorted(d.keys()):
    for j in sorted(d[i].keys()):
        print(d[i][j])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

m = [0]*N

for i in range(N):
    k, v = input().split()
    m[i] = [k, int(v), i+1]

m.sort()

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


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

Submission status: Accepted

Solution code:
N = int(input())
rev = {}
ind_dic = {}
for i in range(1, N+1):
    k, v = input().split()
    
    if k in rev:
        rev[k].append(v)
    else:
        rev[k] = [v]
    ind_dic[v] = i

for v in rev.values():
    for i in range(len(v)):
        v[i] = int(v[i])
    v.sort(reverse=True)

key_lst = []
for k in rev.keys():
    key_lst.append(k)
key_lst.sort()

new_dic = {}
for k in key_lst:
    new_dic[k] = rev[k]

for k in new_dic.keys():
    for i in range(len(new_dic[k])):
        print(ind_dic[str(new_dic[k][i])])

Submission status: Accepted

Solution code:
import numpy as np

N = int(input())
order = np.zeros(N,dtype=np.int)
SP = []
for i in range(N):
  tmp = list(input().split())
  SP.append(tmp)

for i in range(N):
  idx = 0
  for j in range(N):
    if i != j and SP[i][0] > SP[j][0]:
      idx += 1
    elif i != j and SP[i][0] == SP[j][0] and int(SP[i][1]) < int(SP[j][1]):
      idx += 1
  order[idx] = i+1
for i in range(N):
  print(order[i])

Submission status: Accepted

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

res.sort()
for _, _, i in res:
    print(i)

Submission status: Accepted

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

for i in range(N):
  SP[i][1] = -int(SP[i][1])

SP.sort()

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = list(info.keys())
ans.sort(key=lambda i: info[i][1], reverse=True)
ans.sort(key=lambda i: info[i][0])
for i in ans:
    print(i)

Submission status: Accepted

Solution code:
N = int(input())

cities = {}
for i in range(1, N + 1):
    s, p = input().split()
    p = int(p)
    if s in cities:
        cities[s].append((p, i))
    else:
        cities[s] = [(p, i)]
for k in cities.keys():
    cities[k] = list(sorted(cities[k], key=lambda x: x[0], reverse=True))

names = sorted(cities)
for name in names:
    for p, i in cities[name]:
        print(i)

Submission status: Accepted

Solution code:
n = int(input())
dat = []
for i in range(n):
    std_in = input().split()
    dat.append([std_in[0], int(std_in[1])])
     
for i, e in enumerate(dat, start=1):
    e[1] = -e[1]  # 点数を降順ソートするために点数をマイナスにする。
    e.append(i)  # ソート前の順序
     
sorted_list = sorted(dat)  # 都市名と点数のマイナス値で昇順ソート
     
for i, s in enumerate(sorted_list):
    # 順序を出力
    print(sorted_list[i][2])

Submission status: Accepted

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

for i in range(N):
  s,p = input().split()
  l.append([i+1,[s,-int(p)]])
  
sl = sorted(l,key=lambda w: w[1])
for w in sl:
  print(w[0])