Problem:


Score : 300 points

Problem Statement

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?

Constraints

2 \leq N \leq 10^5

1 \leq M \leq 10^5

1 \leq H_i \leq 10^9

1 \leq A_i,B_i \leq N

A_i \neq B_i

Multiple roads may connect the same pair of observatories.

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N M
H_1 H_2 ... H_N
A_1 B_1
A_2 B_2
:
A_M B_M

Output

Print the number of good observatories.

Sample Input 1

4 3
1 2 3 4
1 3
2 3
2 4

Sample Output 1

2

From Obs. 1, you can reach Obs. 3 using just one road. The elevation of Obs. 1 is not higher than that of Obs. 3, so Obs. 1 is not good.

From Obs. 2, you can reach Obs. 3 and 4 using just one road. The elevation of Obs. 2 is not higher than that of Obs. 3, so Obs. 2 is not good.

From Obs. 3, you can reach Obs. 1 and 2 using just one road. The elevation of Obs. 3 is higher than those of Obs. 1 and 2, so Obs. 3 is good.

From Obs. 4, you can reach Obs. 2 using just one road. The elevation of Obs. 4 is higher than that of Obs. 2, so Obs. 4 is good.

Thus, the good observatories are Obs. 3 and 4, so there are two good observatories.

Sample Input 2

6 5
8 6 9 1 2 1
1 3
4 2
4 3
4 6
4 6

Sample Output 2

3



Sample input:
4 3
1 2 3 4
1 3
2 3
2 4


Sample output:
2

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
H=list(map(int,input().split()))

label=[-1]*N
Edge=[[] for _ in range(N)]
for i in range(M):
    A,B=map(int,input().split())
    Edge[A-1].append(B-1)
    Edge[B-1].append(A-1)

out=0
for i in range(N):
    if label[i]==-1:
        S=0
        CN=0
        stack=[i]
        while stack:
            T=stack.pop()
            label[T]=0
            for ii in Edge[i]:
                if label[ii]==-1:
                    stack.append(ii)
                    label[ii]=0
            if S<H[T]:
                S=H[T]
                CN=1
            elif S==H[T]:
                CN=0
        out+=CN
print(out)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
H = list(map(int,input().split()))
H = [0] + H
Tree = [0]
for n in range(N):
  Tree = Tree + [1]
for _ in range(M):
  A,B = map(int,input().split())
  if H[A] >= H[B]:
    H[B] = 0
  else:
    H[A] = 0
print(sum(H))

Submission status: Wrong Answer

Solution code:
N, M = map(int,input().split())
H = list(map(int,input().split()))
michi = [[] for i in range(N)]
 
for i in range(M):
    a,b = map(int,input().split())
    michi[a-1].append(b-1)
    michi[b-1].append(a-1)

 
ans = 0
for i in range(N): #i番目の展望台に注目
    if michi[i] == []:
        print(i)
        ans +=1
    else:
        for j in michi[i]:
        # print(i,j,H[i],H[j]) 
        # このprintを消した
            if H[i] <= H[j]:
            #   不等号を直した
                break
            if j == michi[i][-1]:
                ans += 1
                print(i)
 
print(ans)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
listH = list(map(int,input().split()))
LofS = [set() for i in range(N) ]
for i in range(M):
  a,b=map(int,input().split())
  LofS[a-1].add(b)
  LofS[b-1].add(a)
listMax = []
for i in range(N):
   listMax.append( max( [ listH[j-1] for j in LofS[i] ] , default=0) )
print(listMax)
count = 0
for i in range(N):
  if listH[i] > listMax[i]:
    count += 1
print(count)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
H = []
H = list(map(int,input().split()))
route = []
h_max = []
for i in range(M):
    route.append(list(map(int,input().split())))
for i in range(M):
    if H[route[i][0]-1] > H[route[i][1]-1]:
        h_max.append(route[i][0])
    elif H[route[i][0]-1] < H[route[i][1]-1]:
        h_max.append(route[i][1])
    else:
        h_max.append(route[i][1])
 
print(len(set(h_max)))

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
H = []
H = list(map(int,input().split()))
route = []
h_max = []
for i in range(M):
    route.append(list(map(int,input().split())))
for i in range(M):
    if H[route[i][0]-1] > H[route[i][1]-1]:
        h_max.append(route[i][0])
    elif H[route[i][0]-1] < H[route[i][1]-1]:
        h_max.append(route[i][1])
    else:
        h_max.append(route[i][0])
 
print(len(set(h_max)))

Submission status: Wrong Answer

Solution code:
import numpy as np
N, M = map(int, input().split())
AB = []
H = 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))

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
H=list(map(int,input().split()))

label=[-1]*N
Edge=[[] for _ in range(N)]
for i in range(M):
    A,B=map(int,input().split())
    Edge[A-1].append(B-1)
    Edge[B-1].append(A-1)

out=0
for i in range(N):
    if label[i]==-1:
        S=0
        CN=0
        stack=[i]
        while stack:
            T=stack.pop()
            label[T]=0
            for ii in Edge[i]:
                if label[ii]==-1:
                    stack.append(ii)
                    label[ii]=0
            if S<H[T]:
                S=H[T]
                CN=1
            else:
                CN=0
        out+=CN
print(out)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
H=list(map(int,input().split()))

label=[-1]*N
Edge=[[] for _ in range(N)]
for i in range(M):
    A,B=map(int,input().split())
    Edge[A-1].append(B-1)
    Edge[B-1].append(A-1)

out=0
for i in range(N):
    if label[i]==-1:
        S=0
        CN=0
        stack=[i]
        while stack:
            T=stack.pop()
            label[T]=0
            for ii in Edge[i]:
                if label[ii]==-1:
                    stack.append(ii)
            if S<H[T]:
                S=H[T]
                CN=1
            else:
                CN=0
        out+=CN
print(out)

Submission status: Wrong Answer

Solution code:
n , m = map(int,input().split())

hyoukou = list(map(int,input().split()))

roadssta = []
roadsfin = []

for i in range(m):
    base = input().split()
    roadssta.append(int(base[0]))
    roadsfin.append(int(base[1]))

roadssta = tuple(roadssta)

roadsfin = tuple(roadsfin)


ans = 0

ten = 1

for i in hyoukou:

    if ten not in roadssta and ten not in roadsfin:
        ans += 1
        ten += 1
    
    else:
        access = 0
        stacnt = 0
        fincnt = 0
        
        if ten in roadssta:
            for s in roadssta:
                if s != ten:
                    stacnt += 1    
                else:
                    if i>hyoukou[roadsfin[stacnt]-1]:
                        stacnt += 1
                    else:
                        ten += 1
                        access += 1
                        break
        
        if ten in roadsfin:
            for s in roadsfin:
                if s == ten:
                    fincnt += 1    
                else:
                    if i>hyoukou[roadssta[fincnt]-1]:
                        stacnt += 1
                    else:
                        ten += 1
                        access += 1
                        break
        if access == 0:
            ans += 1
            ten += 1

print(ans)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
list_H = input().split()
list_N=list(range(1,N+1))
for i in range(M):
  A,B = map(int,input().split())
  if list_H[A-1]<list_H[B-1]:
    list_N[A-1]=0
  if list_H[A-1]>list_H[B-1]:
    list_N[B-1]=0
  if list_H[A-1]==list_H[B-1]:
    list_N[A-1]=0
    list_N[B-1]=0
num=0
for i in range(N):
  if list_N[i]!=0:
    print(list_H[i])
    num=num+1
#print(num)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
h = list(map(int,input().split()))
c = dict()
for i in range(m):
    a, b = map(int,input().split())
    if a in c:
        c[a].append(b)
    else:
        c[a] = [b]
    if b in c:
        c[a].append(a)
    else:
        c[b] = [a]
        
cnt = n
for k,v in c.items():
    for i in range(len(v)):
        if h[v[i] - 1] >= h[k - 1]:
            cnt -= 1
            break
print(cnt)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

N ,M = map(int,input().split())
H = list(map(int,input().split()))
graph = defaultdict(list)
for _ in range(M-1):
    A, B = map(int,input().split())
    graph[A].append(H[B-1])
    graph[B].append(H[A-1])

cnt = 0
for i in range(1,N+1):
    t = H[i-1]
    a = -1
    if graph[i]:
        a = max(graph[i])
    if t >a:
        cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
H = list(map(int, input().split())) 
A = [0]*M
B = [0]*M
for i in range(M):
    A[i], B[i] = map(int, input().split())
    A[i] -= 1
    B[i] -= 1
lis = [0]*N
for i in range(M):
    if H[A[i]] >= H[B[i]]:
        lis[B[i]] = -1
    if H[A[i]] <= H[B[i]]:
        lis[A[i]] = -1
    
    print(lis.count(0))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
H = [int(h) for h in input().split()]
ans = [1] * N


# print(H)

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


print(ans.count(1))

Submission status: Wrong Answer

Solution code:

N ,M = list(map(int, input().split()))

H = list(map(int, input().split()))

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


for i in range(1,N+1):
    for j in range(M):
        if AB[j][0] == i:
            if H[AB[j][0]-1] <= H[AB[j][1]-1]:
                print(AB[j],H[AB[j][0]-1],H[AB[j][1]-1])
                break
        if AB[j][1] == i:
            if H[AB[j][0]-1] >= H[AB[j][1]-1]:
                print(AB[j],H[AB[j][0]-1],H[AB[j][1]-1])
                break
    else:
        res.append(i)

print(len(res))

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
mount=list(map(int,input().split()))
mount2=mount[:]

for i in range(m):
    a,b=map(int,input().split())
    y=min(mount[a-1],mount[b-1])
    
    if y in mount2:
        mount2.remove(y)
    else:
        continue


print(len(mount2))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
H = [int(h) for h in input().split()]
ans = [1] * N

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


print(ans.count(1))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

def main():
    N, M = map(int, input().split())
    *H, = map(int, input().split())
    L = []
    for _ in range(M):
        A, B = map(int, input().split())
        if H[A - 1] < H[B -1]:
            L.append(A)
        elif H[A - 1] >= H[B - 1]:
            L.append(B)
    print(N - len(list(set(L))))


main()

Submission status: Wrong Answer

Solution code:
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))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
H = list(map(int, input().split())) 
A = [0]*M
B = [0]*M
for i in range(M):
    A[i], B[i] = map(int, input().split())
    A[i] -= 1
    B[i] -= 1
lis = [0]*N
for i in range(M):
    if H[A[i]] >= H[B[i]]:
        lis[B[i]] = 1
    if H[A[i]] <= H[B[i]]:
        lis[A[i]] = 1
    
    print(lis.count(0))

Submission status: Wrong Answer

Solution code:
def main():
    N, M, *HAB = map(int, open(0).read().split())
    H = [0]*N
    for i in range(N):
        H[i] = HAB[i]
    A, B = [0]*M, [0]*M
    for i in range(M):
        A[i] = HAB[N + 2 * i + 0] - 1
        B[i] = HAB[N + 2 * i + 1] - 1
    # print(N, M, H, A, B)
    ans = set()
    for i in range(M):
        a = A[i]
        b = B[i]
        ha = H[a]
        hb = H[b]
        if ha < hb:
            ans.add(a)
        elif hb < ha:
            ans.add(b)
    print(N - len(ans))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
H = [int(h) for h in input().split()]
Max = [h-1 for h in H]

for _ in range(M):
    ab = [int(_ab)-1 for _ab in input().split()]
    Max[ab[0]] = max(Max[ab[0]], Max[ab[1]])
    Max[ab[1]] = max(Max[ab[0]], Max[ab[1]])

cnt = 0
for n in range(N):
    if H[n] > Max[n]:
        cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
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 = H[a - 1]
    BH = H[b - 1]
    if AH >= BH:
        ans[b - 1] = 0
    if BH >= AH:
        ans[a - 1] = 0


print(ans.count(1))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

def main():
    N, M = map(int, input().split())
    *H, = map(int, input().split())
    L = []
    for _ in range(M):
        A, B = map(int, input().split())
        if H[A - 1] < H[B -1]:
            L.append(A)
        else:
            L.append(B)
    print(N - len(list(set(L))))


main()

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
H = list(map(int, input().split()))
S = []
c = 0
b = []
 
for i in range(m):
    S.append(list(map(int, input().split())))
 
for j in range(n):
    for k in range(m):
        if j in S[k]:
            if S[k][0] == j:
                if H[S[k][0]-1] < H[S[k][1]-1]:
                    c += 1
            else:
                if H[S[k][0]-1] > H[S[k][1]-1]:
                    c += 1
    if c == 0:
        b.append(j)
    c = 0
 
print(len(b))

Submission status: Wrong Answer

Solution code:
def main():
    N, M, *HAB = map(int, open(0).read().split())
    H = [0]*N
    for i in range(N):
        H[i] = HAB[i]
    A, B = [0]*M, [0]*M
    for i in range(M):
        A[i] = HAB[N + 2 * i + 0] - 1
        B[i] = HAB[N + 2 * i + 1] - 1
    # print(N, M, H, A, B)
    ans = set()
    for i in range(M):
        a = A[i]
        b = B[i]
        ha = H[a]
        hb = H[b]
        if ha < hb:
            ans.add(a)
        else:
            ans.add(b)
    print(N - len(ans))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
H = []
H = list(map(int,input().split()))
route = []
h_max = 0
count = 0
h_max_list = []
for i in range(M):
    route.append(list(map(int,input().split())))

for i in range(1,N+1):
    for j in range(M):
        if i in route[j]:
            h_max = max(H[route[j][0]-1],H[route[j][1]-1])
            if H.index(h_max)+1 == i:
                h_max_list.append(H.index(h_max)+1)

print(len(set(h_max_list)))

Submission status: Wrong Answer

Solution code:
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 = H[a - 1]
    BH = H[b - 1]
    if AH >= BH:
        ans[b - 1] = 0
    elif BH >= AH:
        ans[a - 1] = 0


print(ans.count(1))

Submission status: Wrong Answer

Solution code:
def main():
    n,m = map(int,input().split())
    h = list(map(int,input().split()))
    A = [0] * n
    for i in range(m):
        a,b = map(int,input().split())
        A[a-1] = max(A[a-1],h[b-1])
        A[b-1] = max(A[b-1],h[a-1])

    cnt = 0

    for i in range(n):
        if A[i] > h[i]:
            cnt += 1

    print(cnt)
    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
H = input().split()
Hall = [1] * N

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


print(Hall.count(1))

Submission status: Wrong Answer

Solution code:
N, M =map(int, input().split())
H_tree =[0]+[int(n) for n in input().split()]
GOOD_Tree = [0]+[1 for n in range(N)]
 
for i in range(M):
  A, B = map(int, input().split())
  if H_tree[A]>=H_tree[B]:GOOD_Tree[A] = 0
  if H_tree[A]<=H_tree[B]:GOOD_Tree[B] = 0
print(sum(GOOD_Tree))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
h = list(map(int, input().split()))

ma = [0]*n
for _ in range(m):
    a, b = map(int, input().split())
    ma[a-1] = max(b, ma[a-1])
    ma[b-1] = max(a, ma[b-1])

ans = 0
for i in range(n):
    if h[i]>ma[i]:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
N, M = map(int, input().split())
AB = []
H = 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
    elif BH >= AH:
        Hall[a - 1] = 0


print(Hall.count(1))

Submission status: Wrong Answer

Solution code:
def resolve():
  N, M = map(int, input().split(" "))
  H = [int(x) for x in input().split(" ")]

  AB = []
  for i in range(M):
    AB.append([int(x) for x in input().split(" ")])

  count = 0
  for h_index in range(0, N):
    flag = True
    for ab in AB:
      if ab[0] == h_index or ab[1] == h_index:
        if H[ab[0]-1] > H[h_index] or H[ab[1]-1] > H[h_index] or H[ab[0]-1] == H[ab[1]-1]:
          flag = False
          continue

    if flag:
      count += 1

  print(count)


if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
h = list(map(int, input().split()))
 
edeg = [[] for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a -= 1; b -= 1
    edeg[a].append(b)
    edeg[b].append(a)
 
#print(edeg)

ans = 0
for node in range(n):
    good = True
    for neigber in edeg[node]:
        #print("neigber:", neigber)
        if h[node] <= h[neigber]:
            good = False
        if good:
            ans += 1 

print(ans)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
h = list(map(int, input().split()))
 
edeg = [[] for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a -= 1; b -= 1
    edeg[a].append(b)
    edeg[b].append(a)
 
#print(edeg)

ans = 0
for node in range(n):
    good = True
    for neigber in edeg[node]:
        print("neigber:", neigber)
        if h[node] <= h[neigber]:
            good = False
        if good:
            ans += 1 

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
N, M = map(int, input().split())
AB = []
H = input().split()
Hall = [1] * N

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[AB[i][1] - 1] = 0
    elif BH >= AH:
        Hall[AB[i][0] - 1] = 0


print(Hall.count(1))

Submission status: Wrong Answer

Solution code:
N, K    = map(int, input().split())
height  = list(map(int, input().split()))
road    = {}

#道がつながっている辞書を作成
for i in range(K):
    a, b = list(map(int, input().split()))
    try:
        road[a-1].append(b-1)
    except:
        road[a-1] = [b-1]
    try:
        road[b-1].append(a-1)
    except:
        road[b-1] = [a-1]

cnt = 0
for k, v in road.items():
  flag = True
  for i in set(v):
    if height[k] > height[i]:
      pass
    else:
      flag = False
  if flag is True:
    cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
N, M =map(int, input().split())
H_tree =[0]+[int(n) for n in input().split()]
GOOD_Tree = [0]+[1 for n in range(N)]
 
for i in range(M):
  A, B = map(int, input().split())
  if int(H_tree[A])>=int(H_tree[B]):
    GOOD_Tree[A] = 0
  if int(H_tree[A])<=int(H_tree[B]):
    GOOD_Tree[B] = 0
print(sum(GOOD_Tree))

Submission status: Wrong Answer

Solution code:
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])

Hall = [1] * N

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

print(Hall.count(1))

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
h = list(map(int,input().split()))
c = dict()
for i in range(m):
    a, b = map(int,input().split())
    if a in c:
        c[a].append(b)
    else:
        c[a] = [b]
    if b in c:
        c[a].append(a)
    else:
        c[b] = [a]
        
cnt = 0
for k,v in c.items():
    flag = 0
#     print("cur:", h[k - 1])
    for i in range(len(v)):
#         print("    ",h[v[i] - 1])
        if h[v[i] - 1] >= h[k - 1]:
            flag = 1
            break
    if flag == 0:
        cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
from heapq import heappush, heappop


def main():

    N, M = [int(v) for v in input().split()]

    H = [int(v) for v in input().split()]
    link = [0] * N

    for _ in range(M):
        a, b = [int(v) - 1 for v in input().split()]
        link[a] = max(link[a], H[b])
        link[b] = max(link[b], H[a])

    count = 0
    for h, nh in zip(H, link):
        print(h, nh)
        if h > nh:
            count += 1
    print(count)


main()

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
H = []
A = []
H.append(list(map(int,input().split())))

import itertools
h = list(itertools.chain.from_iterable(H))

for i in range(N):
  try:
      a, b = map(int, input().split())
      if h[a-1]<h[b-1]:
        A.append(b)
      else:
        A.append(a)
  except EOFError:
    pass

print(N - len(list(set(A))))

Submission status: Wrong Answer

Solution code:
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)))
not_route = Hall - rall

Hall = [1] * N

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

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)
        Hall[AB[i][1] - 1] = 0
    elif BH >= AH:
        # topH.add(AB[i][1] - 1)
        lowH.add(AB[i][0] - 1)
        Hall[AB[i][0] - 1] = 0

# 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(Hall.count(1))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
H = list(map(int, input().split())) 
A = [0]*M
B = [0]*M
for i in range(M):
    A[i], B[i] = map(int, input().split())
    A[i] -= 1
    B[i] -= 1
lis = []
for i in range(M):
    if H[A[i]] < H[B[i]]:
        lis.append(B[i])
    if H[A[i]] == H[B[i]]:
        lis.append(A[i])
        lis.append(B[i])
    if H[A[i]] > H[B[i]]:
        lis.append(A[i])
print(len(H)-len(set(lis)))

Submission status: Wrong Answer

Solution code:
# C
N, M = map(int, input().split())
H = list(map(int, input().split()))

A = [0] * N
for i in range(M):
    a, b = map(int, input().split())
    A[a-1] = max(A[a-1], H[b-1])
    A[b-1] = max(A[b-1], H[a-1])
    
res = sum([H[i] >= A[i] for i in range(N)])
print(res)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
h_list = input().split(" ")
result = [0 for i in range(n)]
for i in range(m):
    temp1, temp2 = map(int, input().split())
    if h_list[temp1-1] <= h_list[temp2-1]:
        result[temp1-1] = -1
    if h_list[temp1-1] >= h_list[temp2-1]:
        result[temp2-1] = -1
print(result.count(0))

Submission status: Wrong Answer

Solution code:
N, M =map(int, input().split())
H_tree =[int(n) for n in input().split()]
GOOD_Tree = [1 for n in range(N)]
 
for i in range(M):
  A, B = map(int, input().split())
  if int(H_tree[int(A)-1])>=int(H_tree[int(B)-1]):
    GOOD_Tree[A-1] = 0
  else:
    GOOD_Tree[B-1] = 0
print(GOOD_Tree.count(1))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
H = list(map(int, input().split())) 
A = [0]*M
B = [0]*M
for i in range(M):
    A[i], B[i] = map(int, input().split())
    A[i] -= 1
    B[i] -= 1
lis = [0]*M
for i in range(M):
    lis[i] = max(H[A[i]],H[B[i]])
print(len(H)-len(set(lis)))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
h = list(map(int, input().split()))
a_b = []
all_h = []
already_h = []
good_h = []
bad_h = []
for roads in range(m):
    a_b.append(list(map(int, input().split())))

for alls in range(n):
    all_h = h

# print(type(a_b))
# print(type(a_b[0]))
# print((h[a_b[0][0]]))
# print((h[a_b[0][1]]))

for cnt in range(m):
    # print(h[a_b[cnt][0]])
    # print(h[a_b[cnt][1]])
    if h[a_b[cnt][0]-1] not in already_h:
        already_h.append(h[a_b[cnt][0]-1])
    if h[a_b[cnt][1]-1] not in already_h:
        already_h.append(h[a_b[cnt][1]-1])

    if h[a_b[cnt][0]-1] > h[a_b[cnt][1]-1]:
        if h[a_b[cnt][0]-1] not in good_h:
            good_h.append(h[a_b[cnt][0]-1])
        if (h[a_b[cnt][1]-1] in good_h) and (h[a_b[cnt][1]-1] not in bad_h):
            bad_h.append(h[a_b[cnt][1]-1])
    elif h[a_b[cnt][0]-1] < h[a_b[cnt][1]-1]:
        if h[a_b[cnt][1]-1] not in good_h:
            good_h.append(h[a_b[cnt][1]-1])
            if (h[a_b[cnt][0]-1] in good_h) and (h[a_b[cnt][0]-1] not in bad_h):
                bad_h.append(h[a_b[cnt][0]-1])

all_h = list(set(all_h) - set(already_h))
good_h = list(set(good_h) - set(bad_h))
# print("good:", good_h)
# print("bad:", bad_h)
# print("remain:", all_h)
good_h = good_h + all_h

good_num = len(good_h)
print(good_num)

Submission status: Wrong Answer

Solution code:
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('rall', rall)
# print('Hall - rall', Hall - rall)
# print(AB)

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)))

Submission status: Wrong Answer

Solution code:
N, M=map(int,input().split())
H = list(map(int,input().split()))
A=[0]*M
B=[0]*M
for i in range(M):
  A[i],B[i]=map(int,input().split())
ans = 0
C=[[] for i in range(N)]
D=[[] for i in range(N)]
E=[[] for i in range(N)]
for i in range(M):
  C[A[i]-1].append(B[i])
  D[B[i]-1].append(A[i])
for i in range(N):
  E[i]=C[i]+D[i]
 
for i in range(N):
  m=0
  if len(E[i])==0:
    ans += 1
  else:
    for j in range(len(E[i])):
      if len(E[j]) != 0:
        m = max(m,H[E[i][j]-1])
    if H[i]>m:
      ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
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('rall', rall)
# print('Hall - rall', Hall - rall)
# print(AB)

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)))

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
H = list(map(int,input().split()))
p = [0]*n
for i in range(m):
    a,b = map(int,input().split())
    if H[a-1] >= H[b-1]:
        H[b-1] = -1
    if H[a-1] <= H[b-1]:
        H[a-1] = -1
print(p.count(0))

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
h_list = input().split(" ")
result = [True for i in range(n)]
for i in range(m):
    temp1, temp2 = map(int, input().split())
    if h_list[temp1-1] <= h_list[temp2-1]:
        result[temp1-1] = False
    if h_list[temp1-1] >= h_list[temp2-1]:
        result[temp2-1] = False
print(result.count(True))

Submission status: Wrong Answer

Solution code:
N,M = map(int, input().split())
H = list(map(int, input().split()))
A = []
B = []
good = [1]*N
for i in range(M):
    a,b = map(int, input().split())
    if H[a-1] == H[b-1]:
        good[a-1] = 0
        good[b-1] = 0
    else:
        temp = min(H[a-1],H[b-1])
        good[H.index(temp)] = 0
print(sum(good))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
H = list(map(int, input().split())) 
A = [0]*M
B = [0]*M
for i in range(M):
    A[i], B[i] = map(int, input().split())
    A[i] -= 1
    B[i] -= 1
lis = []
for i in range(M):
    if H[A[i]] < H[B[i]]:
        lis.append(A[i])
    if H[A[i]] == H[B[i]]:
        lis.append(A[i])
        lis.append(B[i])
    if H[A[i]] > H[B[i]]:
        lis.append(B[i])
print(len(set(lis)))

Submission status: Wrong Answer

Solution code:
N,M = map(int, input().split())
H = list(map(int, input().split()))
res = [1]*N
for i in range(M):
    a,b = map(int, input().split())
    if H[a-1] <= H[b-1]:
        res[a-1] = 0
    elif H[b-1] <= H[a-1]:
        res[b-1] = 0
print(sum(res))

Submission status: Wrong Answer

Solution code:
import numpy as np
N,M =map(int,input().split())
H_lis=np.array(list(map(int,input().split())))
way_lis=[list(map(int,input().split())) for _ in range(M)]

class tenbou:
    def __init__(self,k):
        self.num=k+1
        self.compare=[]
        for way in way_lis:
            if self.num in way:
                self.compare.extend(way)
    def com(self):
        for j in self.compare:
            max_=max(H_lis[j[0]],H_lis[j[1]])
        if index(max_)+1==self.num:
            return True
        else:
            return False

N_lis=np.array([tenbou(i).com for i in range(N)])
print(N_lis)