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):
from sys import stdin
import numpy as np


def main():
    n, m = list(map(int, stdin.readline().split()))
    hList = list(map(int, stdin.readline().split()))
    ABList = [list(map(int, stdin.readline().split())) for _ in range(m)]
    hRelations = np.zeros((n, n))
    '''
    for a, b in ABList:
        if hList[a-1] >= hList[b-1]:
            hRelations[b-1, a-1] = 1
        if hList[b-1] >= hList[a-1]:
            hRelations[a-1, b-1] = 1
    total = 0
    print(total)
    for hRelation in hRelations:
        if hRelation.sum() == 0:
            total += 1
    print(total)
    '''


if __name__ == '__main__':
    main()


from sys import stdin
import numpy as np


def main():
    n, m = list(map(int, stdin.readline().split()))
    hList = list(map(int, stdin.readline().split()))
    ABList = [list(map(int, stdin.readline().split())) for _ in range(m)]
    '''
    hRelations = np.zeros((n, n))
    for a, b in ABList:
        if hList[a-1] >= hList[b-1]:
            hRelations[b-1, a-1] = 1
        if hList[b-1] >= hList[a-1]:
            hRelations[a-1, b-1] = 1
    total = 0
    print(total)
    for hRelation in hRelations:
        if hRelation.sum() == 0:
            total += 1
    print(total)
    '''


if __name__ == '__main__':
    main()


from sys import stdin
import numpy as np


def main():
    n, m = list(map(int, stdin.readline().split()))
    hList = list(map(int, stdin.readline().split()))
    ABList = [list(map(int, stdin.readline().split())) for _ in range(m)]
    hRelations = np.zeros((n, n))
    for a, b in ABList:
        if hList[a-1] >= hList[b-1]:
            hRelations[b-1, a-1] = 1
        if hList[b-1] >= hList[a-1]:
            hRelations[a-1, b-1] = 1
    total = 0
    print(total)
    for hRelation in hRelations:
        if hRelation.sum() == 0:
            total += 1
    print(total)


if __name__ == '__main__':
    main()


from sys import stdin
import numpy as np


def main():
    n, m = list(map(int, stdin.readline().split()))
    hList = list(map(int, stdin.readline().split()))
    ABList = [list(map(int, stdin.readline().split())) for _ in range(m)]
    hRelations = np.zeros((n, n))
    print(1)
    for a, b in ABList:
        if hList[a-1] >= hList[b-1]:
            hRelations[b-1, a-1] = 1
        if hList[b-1] >= hList[a-1]:
            hRelations[a-1, b-1] = 1
    total = 0
    for hRelation in hRelations:
        if hRelation.sum() == 0:
            total += 1
    print(total)


if __name__ == '__main__':
    main()


from sys import stdin
import numpy as np


def main():
    n, m = list(map(int, stdin.readline().split()))
    hList = list(map(int, stdin.readline().split()))
    ABList = [list(map(int, stdin.readline().split())) for _ in range(m)]
    maxHeights = np.zeros(n)
    for a, b in ABList:
        if hList[a-1] >= maxHeights[b-1]:
            maxHeights[b-1] = hList[a-1]
        if hList[b-1] >= maxHeights[a-1]:
            maxHeights[a-1] = hList[b-1]
    total = 0
    i = 0
    for maxHeight in maxHeights:
        if maxHeight < hList[i]:
            total += 1
        i += 1
    print(total)


if __name__ == '__main__':
    main()


Verdicts: Runtime Error

Wrong Answer

Runtime Error

Runtime Error

Accepted