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: Runtime Error

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

H_list = []

for i in range(N):
    A = [i+1]
    H_list.append(A)

H = input().split()
H = [int(c) for c in H]

for i in range(M):
    A,B = input().split()
    A,B = int(A),int(B)
    if A > B:
        if A not in H_list[B-1]:
            H_list[B-1].append(A)
    else:
        if B not in H_list[A-1]:
            H_list[A-1].append(B)

ans = 0

for i in range(N):
    j = 1
    while j < len(H_list[i]):
        if H[H_list[i][0]-1] <= H[H_list[i][j]-1]:
            H_list[i].clear()
            break
        else:
            H_list[H_list[i][j]].clear()
            j += 1
    if len(H_list[i]) >= 1:
        ans += 1

print(ans)

Submission status: Runtime Error

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

H_list = []

for i in range(N):
    A = [i+1]
    H_list.append(A)

H = input().split()
H = [int(c) for c in H]

for i in range(M):
    A,B = input().split()
    A,B = int(A),int(B)
    if A > B:
        if A not in H_list[B-1]:
            H_list[B-1].append(A)
    else:
        if B not in H_list[A-1]:
            H_list[A-1].append(B)

print(H_list)

ans = 0

for i in range(N):
    j = 1
    while j < len(H_list[i]):
        if H[H_list[i][0]-1] <= H[H_list[i][j]-1]:
            H_list[i].clear()
            break
        else:
            H_list[H_list[i][j]].clear()
            j += 1
    if len(H_list[i]) >= 1:
        ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
H = list(map(int, input().split()))
A = [0] * N
B = [0] * N
for i in range(M):
    A[i], B[i] = map(int, input().split())

ans = 0
for i in range(N):
    count = 0
    good = 0
    for j in range(M):
        if A[j] == i + 1:
            count += 1
            if H[B[j] - 1] < H[i]:
                good += 1
        if B[j] == i + 1:
            count += 1
            if H[A[j] - 1] < H[i]:
                good += 1
    if count == good:
        ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
H=list(map(int,input().split()))
P=[]
for i in range(M):
    P.append(list(map(int,input().split()))) #2次元配列、P[A_i,B_i]

ans=[]

for i in range(M):
    if H[P[i][0]-1]>H[P[i][1]-1]:   #H[A_i]>H[B_i]ならばA_iを加える
        ans.append([P[i][0])
    elif H[P[i][0]-1]<H[P[i][1]-1]: #H[A_i]<H[B_i]ならばB_iを加える
        ans.append(P[i][1])       
    else:                           #H[A_i]=H[B_i]ならば何もしない
        continue                    
    
list=[]

for j in range(M): 
    list+=P[j]

print(len(set(ans))+N-len(set(list)))

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
H=list(map(int,input().split()))
P=[]
for i in range(M):
    P.append(list(map(int,input().split())))

ans=[]

for i in range(M):
  if H[P[i][0]-1]>H[P[i][1]-1]:
    ans.append(H[P[i][0]])
  elif H[P[i][0]-1]<H[P[i][1]-1]:
    ans.append(H[P[i][1]-1])
  else:
    continue
    
list=[]

for j in range(M): 
    list+=P[j]

print(len(set(ans))+N-len(set(list)))

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
h = list(map(int, input().split()))
p = [False] + [True]*n
A = []
B = []
for i in range(m):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)

for i in range(m):
    if h[A[i] - 1] > h[B[i] - 1]:
        p[B[i]] = False
    if h[A[i] - 1] < h[B[i] - 1]:
        p[A[i]] = False
    if h[A[i] - 1] == h[B[i] - 1]:
        p[A[i]] = False
        p[B[i]] = False
    print(p)
ans = [i for i in range(n + 1) if p[i]]

print(len(ans))

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
h = list(map(int, input().split()))
p = [False] + [True]*n
A = []
B = []
for i in range(m):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)

for i in range(m):
    if h[A[i] - 1] > h[B[i] - 1]:
        p[B[i]] = False
    elif h[A[i] - 1] < h[B[i] - 1]:
        p[A[i]] = False
    else:
        p[A[i]] = False
        p[B[i]] = False
    print(p)
ans = [i for i in range(n + 1) if p[i]]

print(len(ans))

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
observes = list(map(int,input().split()))
dic_observe = {}
losers = []
for i in range(1,M+1+1):
    dic_observe[i] = observes[i-1]
for i in range(M):
    Ai,Bi = map(int,input().split())
    if dic_observe[Ai] > dic_observe[Bi]:
        if Bi not in losers:
            losers.append(Bi)
    elif dic_observe[Ai] < dic_observe[Bi]:
        if Ai not in losers:
            losers.append(Ai)
    else:
        if Ai not in losers:
            losers.append(Ai)
        if Bi not in losers:
            losers.append(Bi)
print(len(dic_observe)-len(losers))

Submission status: Runtime Error

Solution code:
4 N,M = map(int,input().split())
observes = list(map(int,input().split()))
dic_observe = {}
losers = []
for i in range(1,M+1+1):
    dic_observe[i] = observes[i-1]
for i in range(M):
    Ai,Bi = map(int,input().split())
    if dic_observe[Ai] > dic_observe[Bi]:
        if Bi not in losers:
            losers.append(Bi)
    elif dic_observe[Ai] < dic_observe[Bi]:
        if Ai not in losers:
            losers.append(Ai)
    else:
        if Ai not in losers:
            losers.append(Ai)
        if Bi not in losers:
            losers.append(Bi)
print(len(dic_observe)-len(losers))

Submission status: Runtime Error

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

l = [1] * n

for i in range(n):
  A,B = map(int,input().split())
  if H[A-1] > H[B-1]:
    l[B - 1] = 0
  elif H[A - 1] < H[B - 1]:
    l[A - 1] = 0
  elif H[A - 1] == H[B - 1]:
    l[A - 1], l[B - 1] = 0, 0
print(l.count(1))

Submission status: Runtime Error

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

l = [1] * N

for i in range(n):
  A,B = map(int,input().split())
  if H[A-1] > h[B-1]:
    l[B - 1] = 0
  elif H[A - 1] < H[B - 1]:
    l[A - 1] = 0
  elif H[A - 1] == H[B - 1]:
    l[A - 1], l[B - 1] = 0, 0
print(l.count(1))

Submission status: Runtime Error

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

l = [1] * N

for i in range(M):
  A,B = map(int,input().split())
  if h[A-1] > h[B-1]:
    l[B - 1] = 0
  elif H[A - 1] < H[B - 1]:
    l[A - 1] = 0
  elif H[A - 1] == H[B - 1]:
    l[A - 1], l[B - 1] = 0, 0
print(l.count(1))

Submission status: Runtime Error

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

l = [0] * N

for i in range(M):
  A,B = map(int,input().split())
  if h[A-1] > h[B-1]:
    l[B - 1] = 0
  elif H[A - 1] < H[B - 1]:
    l[A - 1] = 0
  elif H[A - 1] == H[B - 1]:
    l[A - 1], l[B - 1] = 0, 0
print(l.count(1))

Submission status: Runtime Error

Solution code:

import collections # not needed if here
def f(heights,roads):

count, r =0, [True] * len(heights)
for u,v in roads:
		if heights[u-1] <= heights[v-1]: r[u-1] = False
		if heights[u-1] >= heights[v-1]:r[v-1] = False
	for b in r:
		count += 1 if b else 0
	return count

def f_(heights,roads):
	count, adj = 0,collections.defaultdict(list)
	r = [True] * len()
for u,v in roads:

		adj[u].append(v)
		adj[v].append(u)
	for i,h in enumerate(heights):
		u = i + 1
		if h >= max([heights[v - 1] for v in adj[u]] or [-1]): count +=1
	return count

n,m = map(int, raw_input().split(' '))
print f(map(int,raw_input().split(' ')), [map(int, raw_input().split(' ')) for _ in range(m)] )

Submission status: Runtime Error

Solution code:
import collections
def f(heights,roads):
	adj = collections.defaultdict(list)
	count = 0
	for u,v in roads:
		adj[u].append(v)
		adj[v].append(u)
	for i,h in range(len(heights)):
		u = i + 1
		if h >= max([heights[v-1] for v in adj[u]] or [-1]): count +=1
	return count

n,m = map(int, raw_input().split(' '))
print f(map(int,raw_input().split(' ')), [map(int, raw_input().split(' ')) for _ in range(m)] )

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
h = list(map(int, input().split()))
pairs = [list(map(int, input().split())) for _ in range(m)]

ans = [1] * n

for i in range(m):
    if h[pairs[i][0] - 1] < h[pairs[i][1] - 1]:
        ans[pairs[i][0] - 1] = 0
    elif h[pairs[i][0] - 1] = h[pairs[i][1] - 1]:
        ans[pairs[i][0] - 1] = 0
        ans[pairs[i][1] - 1] = 0 
    else:
        ans[pairs[i][1] - 1] = 0      

print(sum(ans))

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
h = list(map(int, input().split()))
pairs = [list(map(int, input().split())) for _ in range(m)]

ans = [1] * n

for i in range(m):
    if h[pairs[i][0] - 1] < h[pairs[i][1] - 1]:
        ans[pairs[i][0] - 1] = 0
    elif f h[pairs[i][0] - 1] = h[pairs[i][1] - 1]:
        ans[pairs[i][0] - 1] = 0
        ans[pairs[i][1] - 1] = 0 
    else:
        ans[pairs[i][1] - 1] = 0      

print(sum(ans))

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
h = list(map(int, input().split()))
pairs = [list(map(int, input().split())) for _ in range(m)]

ans = [-1] * n

for i in range(m):
    if h[pairs[i][0] - 1] < h[pairs[i][1] - 1]:
            ans[pairs[i][0] - 1] = 0
            if ans[pairs[i][1] - 1] != 0:
                ans[pairs[i][1] - 1] = 1
    else:
        if ans[pairs[i][0] - 1] !=0:
            ans[pairs[i][0] - 1] = 1
        ans[pairs[i][1] - 1] = 0      
    print(ans)
for i in range(n):
    if ans[i] == -1:
        ans[i] = 1
print(ans)
print(sum(ans))

Submission status: Runtime Error

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

ng_h=[]
gd_h=[]

for i in range(m)
 a,b=map(int,input().split())
 ng_h.append(a)
 gd_h.append(b)

 gd_h=list(set(h)+set(gd_h)-set(ng_h))
 
 print(len(gd_h))

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
h=list(map(int,inpt().split()))
ab=[[] for nn in range(n)]
for mm in range(m):
  a,b=map(int,input().split())
  ab[a-1]+=b-1
  ab[b-1]+=a-1
cnt=0
for i in range(n):
  hi=0
  for ll in ab[i]:
    hi=max(hi,h[ll])
  if hi==h[i]:
    cnt+=1
print(cnt)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
a=list(map(int,input().split()))
c=0
deg=[[] for i in range(n)]
for i in range(m):
  u,v=map(int,input().split())
  deg[u-1].append(v-1)
  deg[v-1].append(u-1)
for i in range(n):
  ff=0
  for j in deg[i]:
    if(a[i]>a[deg[i][j]]):
      continue
    ff=1
  if(ff==0):
    c+=1
print(c)

Submission status: Runtime Error

Solution code:
import numpy as np
N,M=map(int,input().split())
S=np.zeros((N,N))
H=list(map(int,input().split()))

for j in range(M):
  a,b=map(int,input().split())
  
  if H[a-1]<H[b-1]:
    S[a-1,b-1]=-1
    S[b-1,a-1]=1
  elif H[a-1]>H[b-1]:
    S[a-1,b-1]=1
    S[b-1,a-1]=-1
  else:
    S[a-1,b-1]=-1
    S[b-1,a-1]=-1

s=np.zeros(N)
for k in range(N+10):
  s[k]=np.any(S[k,:]<0)

print(len([i for i,x in enumerate(s) if x==0]))

Submission status: Runtime Error

Solution code:
h_list = list(map(int, input().split())) #元リスト（変えない）
newlist = list(h_list) #変換用リスト
for i in range(m):
    a, b = map(int, input().split())
    if h_list[a-1] < h_list[b-1]:
        newlist[a-1] = 0
    elif h_list[a-1] > h_list[b-1]:
        newlist[b-1] = 0
    else:
        newlist[a-1] = 0
        newlist[b-1] = 0
print(len(h_list) - newlist.count(0))

Submission status: Runtime Error

Solution code:
h_list = list(map(int, input().split()))
newlist = list(h_list)
for i in range(m):
    a, b = map(int, input().split())
    if h_list[a-1] < h_list[b-1]:
        newlist[a-1] = 0
    elif h_list[a-1] > h_list[b-1]:
        newlistlist[b-1] = 0
    else:
        newlist[a-1] = 0
        newlist[b-1] = 0
print(len(h_list) - newlist.count(0))

Submission status: Runtime Error

Solution code:
h_list = list(map(int, input().split())) #元リスト（変えない）
newlist = list(h_list) #変換用リスト
for i in range(m):
    a, b = map(int, input().split())
    if h_list[a-1] < h_list[b-1]:
        newlist[a-1] = 0
    elif h_list[a-1] > h_list[b-1]:
        newlistlist[b-1] = 0
    else:
        newlist[a-1] = 0
        newlist[b-1] = 0
print(len(h_list) - newlist.count(0))

Submission status: Runtime Error

Solution code:
n,m = map(int, input().split())
h_list = list(map(int, input().split())) #元リスト（変えない）
newlist = list(h_list) #変換用リスト
for i in range(m):
    a, b = map(int, input().split())
    if h_list[a-1] < h_list[b-1]:
        newlist[a-1] = 0
    elif h_list[a-1] > h_list[b-1]:
        newlistlist[b-1] = 0
    else:
        newlist[a-1] = 0
        newlist[b-1] = 0
print(n - newlist.count(0))

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
h = list(map(int, input().split()))
delete_list =[]
pairs = []
for i in range(m):
    a, b = map(int, input().split())
    if h[a-1] > h[b-1]:
        delete_list.append(b)
    if h[a-1] == h[b-1]:
        delete_list.append(a, b)
    else:
        delete_list.append(a)

delete_list = set(delete_list)
print(n - len(delete_list))

Submission status: Runtime Error

Solution code:
x = int(input())
for i in range(-118, 119):
    for j in range(-119, 118):
        if i**5 - j**5 == x:
            print(i,j)
            break
    else:
        continue
    break

Submission status: Runtime Error

Solution code:

n, m =map(int, input().split())  #複数数値入力
list_h=list(map(int, input().split()))  #リスト入力
# 繰り返しリスト入力
a = []
for i in range(m):
    ai = list(map(int, input().split()))  #リスト入力
    a.append(ai)

booler = [True] * n
for i in range(n):
    a_copy = copy.deepcopy(a)
    for j in range(m):
        if i in a_copy[j] :
            a_copy[j].remove(i)
#             print(a_copy)
            if list_h[i] > list_h[a_copy[j][0]-1]:
                continue
            else:
                booler[i] = False
        else:
            continue

print(booler.count(True))

Submission status: Runtime Error

Solution code:
import numpy as np
N,M = (int(x) for x in input().split())
H   = np.array([int(x) for x in input().split()])
Way = np.zeros((N,N),dtype=bool)
for T in range(0,M):
    A,B = (int(x) for x in input().split())
    Way[A-1,B-1] = True
    Way[B-1,A-1] = True
    
Count = 0
#for TT in range(0,N): 
#    TrueIndex = [n for n,v in enumerate(Way[TT,:]) if v==True]
#    if np.all(H[TT]>H[TrueIndex]):
#        Count = Count+1
print(Count)

Submission status: Runtime Error

Solution code:
import numpy as np
N,M = (int(x) for x in input().split())
H   = np.array([int(x) for x in input().split()])
Way = np.zeros((N,N),dtype=bool)
for T in range(0,M):
    A,B = (int(x) for x in input().split())
    Way[A-1,B-1] = True
    Way[B-1,A-1] = True
    
Count = 0
for TT in range(0,N):
    TrueIndex = np.where(Way[TT,:]==True)
    if np.all(H[TT]>H[TrueIndex]):
        Count = Count+1
print(Count)

Submission status: Runtime Error

Solution code:
import numpy as np
N,M = (int(x) for x in input().split())
H   = np.array([int(x) for x in input().split()])
Way = np.zeros((N,N),dtype=bool)
for T in range(0,M):
    A,B = (int(x) for x in input().split())
    Way[A-1,B-1] = True
    Way[B-1,A-1] = True
    
Count = 0
for TT in range(0,N):
    TrueIndex = [Index for Index,Name in enumerate(Way[TT,:]) if Name==True]
    if np.all(H[TT]>H[TrueIndex]):
        Count = Count+1
print(Count)

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline

def ppp(n,m,h,ab):
    g = [1] * n
    for l,r in ab:
        if h[l-1] >= h[r-1]:
            g[r-1] = 0
        if h[l-1] <= h[r-1]:
            g[l-1] = 0
    print(sum(g))
if __name__ == "__main__":
    n,m = map(int,input().split())
    h = list(map(int,input().split()))
    ab = [list(map(int,input().split())) for _ in range(m)]
    ppp(n,m,h,ab_sorted)

Submission status: Runtime Error

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

road_num = list(map(int, input().split()))
road_num = len(road_num)

way_list = []
goal_list = []

for i in range(road_num - 1):
    way, goal = map(int, input().split())
    if not(way in way_list):
        way_list.append(way)
    if not(goal in way_list) and not(goal in goal_list):
        goal_list.append(goal)

print(len(goal_list))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

l = [1]*n
for i in range(m):
    a, b= map(int, readline().split())
    if h[a - 1] < h[b - 1]:
        l[a - 1] = 0
    elif h[a - 1] > h[b - 1]:
        l[b - 1] = 0
    else:
        l[a - 1] = 0
        l[b - 1] = 0
print(sum(l))

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
tenbo_height = list(map(int, input().split()))
roads = []
for i in range(M):
  #road[0] = start, road[1] = goal
  road = list(map(int, input().split()))
  roads.append(road)

good_tenbo = 0
for tenbo in range(N):
  adjacent_tenbo = []
  #good tenbo if no road or adjacent tenbo is all lower
  #count number of road connected to this tenbo
  for road in roads:
    if (road[0] == tenbo):
      adjacent_tenbo.append(road[1])
    elif (road[1] == tenbo):
      adjacent_tenbo.append(road[0])
  
  #check if no road connected
  if (len(adjacent_tenbo) == 0):
    good_tenbo += 1
    continue
  #check if adjacent tenbo is all lower
  all_lower = True
  for a_tenbo in adjacent_tenbo:
    if (tenbo_height[a_tenbo] >= tenbo_height[tenbo]):
      all_lower = False
      break
  if (all_lower):
    good_tenbo += 1
    continue
    
print(good_tenbo)

Submission status: Runtime Error

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

S=[1]*N

 
for m in range(M)
  if H[A[m]-1] == H[B[m]-1]:
    S[A[m]-1] = 0
    S[B[m]-1] = 0
  elif H[A[m]-1] <= H[B[m]-1]:
    S[A[m]-1] = 0
  elif H[A[m]-1] >= H[B[m]-1]
    S[B[m]-1] = 0

 
print(sum(S))

Submission status: Runtime Error

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


count = 0

for i in range(1,N+1):
  flag = 0
  for m in range(M):
    if i == A[m] and H[i-1]<= H[B[m]-1]:
      print('a'+A[i]+','+B[i])
      print(H[i-1]+','+H[B[m]-1])
      flag = 1
      continue
    elif i == B[m] and H[i-1]<=H[A[m]-1]:
      print('b'+A[i]+','+B[i])
      print(H[i-1]+','+H[B[m]-1])
      flag = 1
      continue
     
  if not flag:
    print(i)
    count += 1

print(count)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
A = list(map(int,input().split()))
B = [ [] for _ in range(n + 1) ]
for _ in range(m):
    s,e = map(int,input().split())
    B[s].append(e)
    B[e].append(s)
ans = 0
for i in range(1,n+1):
    if max(B[i]) < i:
        ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
N,M = (int(x) for x in input().split())
H   = np.array([int(x) for x in input().split()])
Way = np.zeros((N,N),dtype=bool)
for T in range(0,M):
    A,B = (int(x) for x in input().split())
    Way[A-1,B-1] = True
    Way[B-1,A-1] = True
    
Count = 0
for TT in range(0,N):
    TrueIndex = [n for n,v in enumerate(Way[TT,:]) if v==True]
    if np.all(H[TT]>H[TrueIndex]):
        Count = Count+1
print(Count)

Submission status: Runtime Error

Solution code:
import numpy as np
N,M = (int(x) for x in input().split())
H   = np.array([int(x) for x in input().split()])
Way = np.zeros((N,N),dtype=bool)
for T in range(0,M):
    A,B = (int(x) for x in input().split())
    Way[A-1,B-1] = True
    Way[B-1,A-1] = True
    
Count = 0
for TT in range(0,N):
    TrueIndex = [n for n,v in enumerate(Way[TT,:]) if v==True]
    if all(H[TT]>H[TrueIndex]):
        Count = Count+1
print(Count)

Submission status: Runtime Error

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

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

res = 0
for i range(N):
    if H[i] > t[i]:
        res += 1

print(res)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
h = list(map(int, input().split()))
ab = [0] * m
for i in range(m):
    ab[i] = list(map(int, input().split()))
check = [1] * n

for i in range(m):
    #低かったほうのチェックリストを0にしていく
    if h[ab[i][0]-1] = h[ab[i][1]-1]:
        check[ab[i][0]-1] = 0
        check[ab[i][1] - 1] = 0
    elif h[ab[i][0] - 1] < h[ab[i][1]-1]:
        check[ab[i][0] - 1] = 0
    else:
        check[ab[i][1]-1] = 0
print(sum(check))

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
h=[0]+list(map(int, input().split()))
roads=[[] for _ in range(n+1)]
cnt=0
for i in range(m):
    a,b=map(int,input().split())
    roads[a].append(b)
    roads[b].append(a)
 
for i in range(1,n+1):
    for j in roads[i]:
        if h[i]<=h[j]:
            break
    else:
         cnt+=1
    
print(cnt

Submission status: Runtime Error

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

for j in range(n):
  for k in ab[j]:
    if h[j] <= h[k]:
      check[j] = True
      
print(check.count(True))

Submission status: Runtime Error

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

for j in range(n):
  for k in ab[j]:
    if k < h[j]:
      check[j] = True
    elif k > h[j]:
      check[j] = False
	else:
      check[j] = False

print(check.count(True))

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
tree = list(map(int,input().split())) #比較用
tree_sub = tree #データの削除用
count = 0
for i in range(M):
    a,b = map(int,input().split())
    if (tree[a-1] > tree[b-1]) and (tree[b-1]== tree_sub[b-1]):
        tree_sub[b-1] = 0
    elif (tree[a-1] < tree[b-1]) and (tree[a-1] == tree_sub[a-1]):
        tree_sub[a-1] = 0
for i in range(M):
    if tree_sub[i] !=0:
        count += 1
print(count)

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
tree = list(map(int,input().split())) #比較用
tree_sub = tree #データの削除用
for i in range(M):
    a,b = map(int,input().split())
    if (tree[a-1] > tree[b-1]) and (int(tree[b-1]) in tree_sub):
        tree_sub[b-1] = 0
    elif (tree[a-1] < tree[b-1]) and (tree[a-1] in tree_sub):
        tree_sub[a-1] = 0
count = 0
for i in range(M):
    if tree_sub[i] != 0:
        count += 1
print(count)

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
tree = list(map(int,input().split())) #比較用
tree_sub = tree #データの削除用
for i in range(M):
    a,b = map(int,input().split())
    if (tree[a-1] > tree[b-1]) and (tree[b-1] in tree_sub):
        tree_sub.remove(b)
    elif (tree[a-1] < tree[b-1]) and (tree[b-1] in tree_sub):
        tree_sub.remove(a)
print(len(tree_sub))

Submission status: Runtime Error

Solution code:
import numpy as np
n,m = map(int,input().split())
H = list(map(int,input().split()))
A=np.zeros((n,n))
for i in range(m):
    a,b=input().split()
    A[int(a)-1][int(b)-1]=1
    A[int(b)-1][int(a)-1]=1
count = 0  
for i in range(n):
  best =  0
  for j in range(n):
      if A[i][j]==1 :
        best = max(best,H[j])  
  if H[i] > best:
    count =count +1
print(count)

Submission status: Runtime Error

Solution code:
import numpy as np
n,m = map(int,input().split())
if m < 1 or n <2:
  exit()
H = list(map(int,input().split()))
A=np.zeros((n+1,n+1))
for i in range(m):
    a,b=input().split()
    A[int(a)-1][int(b)-1]=1
    A[int(b)-1][int(a)-1]=1
count = 0  
for i in range(n):
  best =  0
  for j in range(n):
      if A[i][j]==1 :
        best = max(best,H[j])  
  if H[i] > best:
    count =count +1
print(count)

Submission status: Runtime Error

Solution code:
import numpy as np
n,m = map(int,input().split())
H = list(map(int,input().split()))
A=np.zeros((n+1,n+1))
for i in range(m):
    a,b=input().split()
    A[int(a)-1][int(b)-1]=1
    A[int(b)-1][int(a)-1]=1
count = 0  
for i in range(n):
  best =  0
  for j in range(n):
      if A[i][j]==1 :
        best = max(best,H[j])  
  if H[i] > best:
    count =count +1
print(count)

Submission status: Runtime Error

Solution code:
import numpy as np
n,m = map(int,input().split())
H = list(map(int,input().split()))
A=np.zeros((n+1,n+1))
for i in range(m):
    a,b=input().split()
    A[int(a)-1][int(b)-1]=1
    A[int(b)-1][int(a)-1]=1
count = 0  
for i in range(n):
  best =  0
  for j in range(n):
      if A[i][j]==1 :
        best = max(best,H[j])  
  if H[i] > best:
    count +=1
print(count)

Submission status: Runtime Error

Solution code:
import numpy as np
import sys
sys.setrecursionlimit(10**9)
n,m = map(int,input().split())
H = list(map(int,input().split()))
A=np.zeros((n+1,n+1))
for i in range(m):
    a,b=input().split()
    A[int(a)-1][int(b)-1]=1
    A[int(b)-1][int(a)-1]=1
count = 0  
for i in range(n):
  best =  [0]
  for j in range(n):
      if A[i][j]==1 :
        best.append(H[j])      
  if H[i] > max(best):
    count +=1
print(count)

Submission status: Runtime Error

Solution code:
import numpy as np
import sys
sys.setrecursionlimit(10**9)
n,m = map(int,input().split())
H = list(map(int,input().split()))
A=np.zeros((n+1,n+1))
for i in range(m):
    a,b=input().split()
    A[int(a)-1][int(b)-1]=1
    A[int(b)-1][int(a)-1]=1
count = 0  
for i in range(n):
  best =  [0]
  for j in range(n):
      if A[i][j]==1 :
        best.append(H[j])      
  if H[i] > max(best):
    count +=1
print(count)

Submission status: Runtime Error

Solution code:
import numpy as np
import sys
sys.setrecursionlimit(10**6)
n,m = map(int,input().split())
H = list(map(int,input().split()))
A=np.zeros((n+1,n+1))
for i in range(m):
    a,b=input().split()
    A[int(a)-1][int(b)-1]=1
    A[int(b)-1][int(a)-1]=1
count = 0  
for i in range(n):
  best =  [0]
  for j in range(n):
      if A[i][j]==1 :
        best.append(H[j])      
  if H[i] > max(best):
    count +=1
print(count)

Submission status: Runtime Error

Solution code:
import numpy as np
n,m = map(int,input().split())
H = list(map(int,input().split()))
A=np.zeros((n+1,n+1))
for i in range(m):
    a,b=input().split()
    A[int(a)-1][int(b)-1]=1
    A[int(b)-1][int(a)-1]=1
count = 0  
for i in range(n):
  best =  [0]
  for j in range(n):
      if A[i][j]==1 :
        best.append(H[j])      
  if H[i] > max(best):
    count +=1
print(count)

Submission status: Runtime Error

Solution code:
import numpy as np
n,m = map(int,input().split())
H = list(map(int,input().split()))
A=np.zeros((n+1,n+1))
for i in range(m):
    a,b=input().split()
    A[int(a)-1][int(b)-1]=1
    A[int(b)-1][int(a)-1]=1
count = 0  
for i in range(n):
  best = H[i]
  for j in range(n):
      if A[i][j]==1 and best < H[j]:
        best = H[j]
        break
      elif A[i][j]==1 and best == H[j]:
        best = float('inf')
        break
  if best == H[i]:
    count +=1
print(count)

Submission status: Runtime Error

Solution code:
import numpy as np
n,m = map(int,input().split())
H = list(map(int,input().split()))
A=np.zeros((n+1,n+1))
for i in range(m):
    a,b=input().split()
    A[int(a)-1][int(b)-1]=1
    A[int(b)-1][int(a)-1]=1
count = 0  
for i in range(n):
  best = H[i]
  for j in range(n):
      if A[i][j]==1 and best < H[j]:
        best = H[j]
      elif A[i][j]==1 and best == H[j]:
        best = 10000000000
  if best == H[i]:
    count +=1
print(count)

Submission status: Runtime Error

Solution code:
import numpy as np
n,m = map(int,input().split())
H = list(map(int,input().split()))
A=np.zeros((n+1,n+1))
for i in range(m):
    a,b=input().split()
    A[int(a)-1][int(b)-1]=1
    A[int(b)-1][int(a)-1]=1
count = 0  
for i in range(n):
  best = H[i]
  for j in range(n):
      if A[i][j]==1 and best < H[j]:
        best = H[j]
      elif A[i][j]==1 and best == H[j]:
        best = 5000
  if best == H[i]:
    count +=1
print(count)

Submission status: Runtime Error

Solution code:
import numpy as np
n,m = map(int,input().split())
H = list(map(int,input().split()))
A=np.zeros((n,n))
for i in range(m):
    a,b=input().split()
    A[int(a)-1][int(b)-1]=1
    A[int(b)-1][int(a)-1]=1
count = 0    
for i in range(n):
  best = H[i]
  for j in range(n):
      if A[i][j]==1 and best <= H[j]:
        best = H[j]
  if best == H[i]:
    count += 1
print(count)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
tower_height = list(map(int, input().split()))
tower_route = [list(map(int, input().split())) for i in range(M)]

lose_list = []
for i in range(M):
    if tower_height[tower_route[i][0] - 1] > tower_height[tower_route[i][1] - 1]:
        lose_list.append(tower_height[tower_route[i][1]-1])
        try:
            lose_list.remove(tower_height[tower_route[i][0]-1])
        except ValueError:
            continue
    elif tower_height[tower_route[i][0] - 1] < tower_height[tower_route[i][1] - 1]:
        lose_list.append(tower_height[tower_route[i][0]-1])
        try:
            lose_list.remove(tower_height[tower_route[i][1]-1])
        except ValueError:
            continue
    print(lose_list)

print((list(set(tower_height) - set(lose_list))))

Submission status: Runtime Error

Solution code:
# C
import numpy as np
N,M = map(int,input().split())
H = list(map(int,input().split()))
edge = [[]]*N
for i in range(M):
    A,B = map(int,input().split())
    edge[A-1] = edge[A-1]+[H[B-1]]
    edge[B-1] = edge[B-1]+[H[A-1]]

count = 0
for i in range(N):
    print(i)
    if H[i] > max(edge[i]):
        count = count+1
    else:
        pass
print(count)