Problem: 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.

Submission attempts (in order):
N=int(input())
data=[input().split() for i in range(N)]
data_name=[]
for i in range(N):
    if data[i][0] in data_name:
        continue
    else:
        data_name.append(data[i][0])
data_name_sort=sorted(data_name)
data_point=[]
for i in range(N):
    num=0
    for j in range(len(data_name_sort)):
        if data[i][0]==data_name_sort[j]:
            num+=(len(data_name)-j)*100+int(data[i][1])
        else:
            continue
    data_point.append(num)
data_sort=[i for i, _ in sorted(enumerate(data_point), key=lambda x:x[1])][::-1]
for i in range(N):
    ans=int(data_sort.index(i))+1
    print(ans)

N=int(input())
data=[input().split() for i in range(N)]
data_name=[]
for i in range(N):
    if data[i][0] in data_name:
        continue
    else:
        data_name.append(data[i][0])
data_name_sort=sorted(data_name)
data_point=[]
for i in range(N):
    num=0
    for j in range(len(data_name_sort)):
        if data[i][0]==data_name_sort[j]:
            num+=(len(data_name)-j)*101+int(data[i][1])
        else:
            continue
    data_point.append(num)
data_sort=[i for i, _ in sorted(enumerate(data_point), key=lambda x:x[1])][::-1]
for i in range(N):
    ans=int(data_sort.index(i))+1
    print(ans)

N=int(input())
data=[input().split() for i in range(N)]
data_name=[]
for i in range(N):
    if data[i][0] in data_name:
        continue
    else:
        data_name.append(data[i][0])
data_name_sort=sorted(data_name)
data_point=[]
for i in range(N):
    num=0
    for j in range(len(data_name_sort)):
        if data[i][0]==data_name_sort[j]:
            num+=(len(data_name)-j)*200+int(data[i][1])
        else:
            continue
    data_point.append(num)
data_sort=[i for i, _ in sorted(enumerate(data_point), key=lambda x:x[1])][::-1]
for i in range(N):
    ans=int(data_sort(i))+1
    print(ans)

N=int(input())
d=[input().split() for i in range(N)]
name=[]
for i in range(N):
    d[i].append(i+1)
    name.append(d[i][0])
Name=list(set(name))
Name.sort()
print(Name)
d.sort()
for i in range(len(Name)):
    li=[]
    for j in range(N):
        if Name[i]==d[j][0]:
            li.append([d[j][1],d[j][2]])
        else:
            continue
    li.sort()
    Li=li[::-1]
    for k in range(len(li)):
        print(Li[k][1])

N=int(input())
data=[input().split() for i in range(N)]
data_name=[]
for i in range(N):
    if data[i][0] in data_name:
        continue
    else:
        data_name.append(data[i][0])
data_name_sort=sorted(data_name)
data_point=[]
for i in range(N):
    num=0
    for j in range(len(data_name_sort)):
        if data[i][0]==data_name_sort[j]:
            num+=(len(data_name)-j)*200+int(data[i][1])
        else:
            continue
    data_point.append(num)
data_sort=[i for i, _ in sorted(enumerate(data_point), key=lambda x:x[1])][::-1]
for i in range(N):
    ans=int(data_sort.index(i))+1
    print(ans)

N=int(input())
data_pre=[input().split() for i in range(N)]
data_name=[]
for i in range(N):
    if data[i][0] in data_name:
        continue
    else:
        data_name.append(data[i][0])
data_name_sort=sorted(data_name)
data_point=[]
for i in range(N):
    num=0
    for j in range(len(data_name_sort)):
        if data[i][0]==data_name_sort[j]:
            num+=(len(data_name)-j)*100+int(data[i][1])
        else:
            continue
    data_point.append(num)
data_sort=[i for i, _ in sorted(enumerate(data_point), key=lambda x:x[1])][::-1]
for i in range(N):
    ans=int(data_sort.index(i))+1
    print(ans)

N=int(input())
data=[input().split() for i in range(N)]
data_name=[]
for i in range(N):
    if data[i][0] in data_name:
        continue
    else:
        data_name.append(data[i][0])
data_name_sort=sorted(data_name)
#print(data_name_sort)
data_point=[]
for i in range(N):
    num=0
    for j in range(len(data_name_sort)):
        if data[i][0]==data_name_sort[j]:
            num+=(len(data_name)-j)*200+int(data[i][1])
        else:
            continue
    data_point.append(num)
#print(data_point)
data_sort=[i for i, _ in sorted(enumerate(data_point), key=lambda x:x[1])][::-1]
#print(data_sort)
for i in range(N):
    ans=int(data_sort(i))+1
    print(ans)

N=int(input())
d=[input().split() for i in range(N)]
name=[]
for i in range(N):
    d[i].append(i+1)
    d[i][1]=int(d[i][1])
    name.append(d[i][0])
Name=list(set(name))
Name.sort()
d.sort()
for i in range(len(Name)):
    li=[]
    for j in range(N):
        if Name[i]==d[j][0]:
            li.append([d[j][1],d[j][2]])
        else:
            continue
    li.sort()
    Li=li[::-1]
    for k in range(len(li)):
        print(Li[k][1])

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Runtime Error

Runtime Error

Accepted