Problem: There are N observatories in AtCoder Hill, called Obs. 1, Obs. 2, ..., Obs. N. The elevation of Obs. i is H_i. There are also M roads, each connecting two different observatories. Road j connects Obs. A_j and Obs. B_j.  Obs. i is said to be good when its elevation is higher than those of all observatories that can be reached from Obs. i using just one road. Note that Obs. i is also good when no observatory can be reached from Obs. i using just one road.  How many good observatories are there?

Submission attempts (in order):
N, M = map(int, input().split())
H = input().split()
ans = [1] * N

print(H)
for i in range(M):
    a, b = map(int, input().split())
    AH = int(H[a - 1])
    BH = int(H[b - 1])
    if AH >= BH:
        ans[b - 1] = 0
    elif BH >= AH:
        ans[a - 1] = 0


print(ans.count(1))


import numpy as np
N, M = map(int, input().split())
H = []
AB = []
H = input().split()

for _ in range(M):
    a, b = map(int, input().split())
    AB.append([a, b])

c = 0
topH = set([])
rall = set((np.array(AB).flatten() - 1).tolist())
Hall = set(list(range(N)))
# print(rall)
# print(Hall - rall)

for i in range(M):
    AH = H[AB[i][0] - 1]
    BH = H[AB[i][1] - 1]
    if AH > BH:
        topH.add(AB[i][0] - 1)
        # if AB[i][1] - 1 in topH:
        #     topH.remove(AB[i][1] - 1)
    elif BH > AH:
        topH.add(AB[i][1] - 1)
        # if AB[i][0] - 1 in topH:
        #     topH.remove(AB[i][0] - 1)
    # else:
    #     if AB[i][1] - 1 in topH:
    #         topH.remove(AB[i][1] - 1)
    #     if AB[i][0] - 1 in topH:
    #         topH.remove(AB[i][0] - 1)

tmp = Hall - rall
topH = topH | tmp

print(topH)

for i in list(topH):
    flg = True
    Hi = int(H[i])
    # print(topH)
    for m in range(M):
        if i + 1 in AB[m]:
            o_idx = 1 - AB[m].index(i + 1)
            h_idx = AB[m][o_idx]-1
            otherH = int(H[h_idx])
            # print(AB[m], i+1, o_idx, otherH, Hi)
            if Hi <= otherH:
                flg = False
                break

    if flg:
        c += 1

#     # print('c', c)

print(c)
# print(len(topH))


import numpy as np
N, M = map(int, input().split())
H = []
AB = []
H = input().split()

for _ in range(M):
    a, b = map(int, input().split())
    AB.append([a, b])

topH = set([])
lowH = set([])
rall = set((np.array(AB).flatten() - 1).tolist())
Hall = set(list(range(N)))

# print('Hall - rall', Hall - rall)


for i in range(M):
    print(AB[i])
    AH = H[AB[i][0] - 1]
    BH = H[AB[i][1] - 1]
    # print(AB[i][0] - 1, AB[i][1] - 1)
    if AH >= BH:
        # topH.add(AB[i][0] - 1)
        lowH.add(AB[i][1] - 1)
    elif BH >= AH:
        # topH.add(AB[i][1] - 1)
        lowH.add(AB[i][0] - 1)

# print('topH', topH)
print('lowH', lowH)

real_topH = (topH - lowH)
# print(topH)
tmp = (Hall) - rall
real_topH = real_topH | tmp
# print((Hall) - rall)
# print(Hall - lowH)
print(len(((Hall) - rall) | (Hall - lowH)))


import numpy as np
N, M = map(int, input().split())
H = []
AB = []
H = input().split()

for _ in range(M):
    a, b = map(int, input().split())
    AB.append([a, b])

c = 0
topH = set([])
rall = set((np.array(AB).flatten() - 1).tolist())
Hall = set(list(range(N)))
# print(rall)
# print(Hall - rall)

for i in range(M):
    AH = H[AB[i][0] - 1]
    BH = H[AB[i][1] - 1]
    if AH > BH:
        topH.add(AB[i][0] - 1)
        if AB[i][1] - 1 in topH:
            topH.remove(AB[i][1] - 1)
    elif BH > AH:
        topH.add(AB[i][1] - 1)
        if AB[i][0] - 1 in topH:
            topH.remove(AB[i][0] - 1)
    else:
        if AB[i][1] - 1 in topH:
            topH.remove(AB[i][1] - 1)
        if AB[i][0] - 1 in topH:
            topH.remove(AB[i][0] - 1)

tmp = Hall - rall
topH = topH | tmp

print(topH)


#     flg = True
#     Hi = int(H[i])
#     # print(topH)
#     for m in range(M):

#             o_idx = 1 - AB[m].index(i + 1)
#             h_idx = AB[m][o_idx]-1
#             otherH = int(H[h_idx])
#             # print(AB[m], i+1, o_idx, otherH, Hi)
#             if Hi <= otherH:
#                 flg = False
#                 break

#     if flg:
#         c += 1

#     # print('c', c)

# print(c)
print(len(topH))


import numpy as np
N, M = map(int, input().split())
H = []
AB = []
H = input().split()

for _ in range(M):
    a, b = map(int, input().split())
    AB.append([a, b])

c = 0
topH = set([])
rall = set((np.array(AB).flatten() - 1).tolist())
Hall = set(list(range(N)))
# print(rall)
# print(Hall - rall)

for i in range(M):
    AH = H[AB[i][0] - 1]
    BH = H[AB[i][1] - 1]
    if AH > BH:
        topH.add(AB[i][0] - 1)
        if AB[i][1] - 1 in topH:
            topH.remove(AB[i][1] - 1)
    elif BH > AH:
        topH.add(AB[i][1] - 1)
        if AB[i][0] - 1 in topH:
            topH.remove(AB[i][0] - 1)

tmp = Hall - rall
topH = topH | tmp

print(topH)


#     flg = True
#     Hi = int(H[i])
#     # print(topH)
#     for m in range(M):

#             o_idx = 1 - AB[m].index(i + 1)
#             h_idx = AB[m][o_idx]-1
#             otherH = int(H[h_idx])
#             # print(AB[m], i+1, o_idx, otherH, Hi)
#             if Hi <= otherH:
#                 flg = False
#                 break

#     if flg:
#         c += 1

#     # print('c', c)

# print(c)
print(len(topH))


import numpy as np
N, M = map(int, input().split())
AB = []
H = [int(h) for h in input().split()]
Hall = [1] * N
 
# print(H)
for i in range(M):
    a, b = map(int, input().split())
    AB.append([a, b])
    AH = H[a - 1]
    BH = H[b - 1]
    if AH >= BH:
        Hall[b - 1] = 0
    if BH >= AH:
        Hall[a - 1] = 0
 
 
print(Hall.count(1))

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted