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=map(int,input().split())
h=list(map(int,input().split()))
count=[1]*m
for i in range(m):
  a,b=map(int,input().split())
  if h[a-1]>h[b-1]:
    count[b-1]=0
  elif h[a-1]==h[b-1]:
    count[a-1]=0
    count[b-1]=0
  else:
    count[b-1]=0
print(sum(count))

Submission status: Runtime Error

Solution code:
import numpy as np

def main():
    N, M  = list(map(int, input().split()))
    H     = list(map(int, input().split()))
    edges = np.zeros((N, N))
        
    for itr in range(M):
        A, B = list(map(int, input().split()))
        edges[A- 1][B- 1] = H[B- 1]
        edges[B- 1][A- 1] = H[A- 1]
    
    result = 0
    for itr in range(N):
        count = 1
        for inner_itr in range(N):
            if edges[itr][inner_itr] >= H[itr] :
                count = 0
                break
        result += count
        #print(itr, result, H[itr])
    
    print(result)
    #print(edges)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import numpy as np

def main():
    N, M  = list(map(int, input().split()))
    H     = list(map(int, input().split()))
    edges = np.zeros((N, N))
        
    for itr in range(M):
        A, B = list(map(int, input().split()))
        if H[A - 1] >= H[B- 1] :
            edges[A - 1][B- 1] = H[A- 1]
            edges[B - 1][A- 1] = H[B- 1]
        else :
            edges[A - 1][B- 1] = H[B- 1]
            edges[B - 1][A- 1] = H[A- 1]
    
    result = 0
    for itr in range(N):
        count = 1
        for inner_itr in range(N):
            if edges[itr][inner_itr] >= H[itr] :
                count = 0
                break
        result += count
    
    print(result)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import copy
n,m = map(int,input().split())
ht = [x for x in input().split()]
hl = {ht.index(x) + 1 : int(x) for x in ht}
p = []
for i in range(m):
    p.append([int(x) for x in input().split()])
hl2 = copy.copy(hl)
p2 = copy.copy(p)
g = []
for h in hl:
    if not (h in hl2):
        continue
    c = False
    for pt in p2:
        if not (h in pt):
            continue
        gp = copy.copy(pt)
        l = gp.pop(pt.index(h))
        lh = hl[l]
        r = gp.pop()
        rh = hl[r]
        if lh <= rh:
            c = True
            break
        if r in hl2:
            hl2.pop(r)
    if not c:
        g.append(h)
print(len(g))

Submission status: Runtime Error

Solution code:
NM=list(map(int,input().split()))
person=[0 for i in range(NM[0])]
for i in range(NM[1]):
    d=input() 
    snack=list(map(int,input().split()))
    for i in snack:
        person[i-1]=1
d=0
for i in range(len(person)):
    if person[i]==0:
        d+=1
print(d)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
h = list(map(int,input().split()))
x = [list(map(int,input().split())) for nesya in range(m)]
k = [1]*n
for route in x:
  h1 = route[0]-1
  h2 = route[1]-1
  if h[h1] < h[h2]:
    k[h1] = 0
  elif h[h1] > h[h2]
    k[h2] = 0
print(sum(k))

Submission status: Runtime Error

Solution code:
N,M=map(int, input().split())
H=list(map(int,input().split()))
List=[list(map(int,input().split())) for i in range(M)]
ans=0
alllist=[[0 for i in range(N)]for j in range(N)]

for j in range(M):
    alllist[List[j][0]-1][List[j][1]-1]=1
    alllist[List[j][1]-1][List[j][0]-1]=1


for s in range(M):
    flag=True
    for t in range(M):
        if H[s]<alllist[s][t]*H[t]:
            flag=False
            break
    if flag:
        ans=ans+1

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from collections import defaultdict

def DFS(u,G,H,A,visited,P):
    visited[u]=True
    for v in G[u]:
        if not (min(u,v),max(u,v)) in P:
            if H[u-1]>H[v-1]:
                    A[u]+=1
            elif H[v-1]>H[u-1]:
                    A[v]+=1
            P.add((min(u,v),max(u,v)))
        if not visited[v]:
            DFS(v,G,H,A,visited,P)

def DFSUtil(G,H,N):
    visited=[False]*(N+100)
    A=[0]*(N+100)
    P=set()
    for u in G:
        if (not visited[u]):
            DFS(u,G,H,A,visited,P)
    return A
N,M=map(int,input().strip().split())
H=list(map(int,input().strip().split()))
G=defaultdict(list)

for i in range(M):
    u,v=map(int,input().strip().split())
    G[u].append(v)
    G[v].append(u)
A=DFSUtil(G,H,N)
cnt=0
for i in range(1,N+1):
    neighbours=len(list(set(G[i])))
    if neighbours==A[i]:
        cnt+=1
print(cnt)

Submission status: Runtime Error

Solution code:
from collections import defaultdict

def DFS(u,G,H,A,visited,P):
    visited[u]=True
    for v in G[u]:
        if not (min(u,v),max(u,v)) in P:
            if H[u-1]>H[v-1]:
                    A[u]+=1
            elif H[v-1]>H[u-1]:
                    A[v]+=1
            P.add((min(u,v),max(u,v)))
        if not visited[v]:
            DFS(v,G,H,A,visited,P)

def DFSUtil(G,H,N):
    visited=[False]*(N+1)
    A=[0]*(N+1)
    P=set()
    for u in G:
        if (not visited[u]):
            DFS(u,G,H,A,visited,P)
    return A
N,M=map(int,input().strip().split())
H=list(map(int,input().strip().split()))
G=defaultdict(list)

for i in range(M):
    u,v=map(int,input().strip().split())
    G[u].append(v)
    G[v].append(u)
A=DFSUtil(G,H,N)
cnt=0
for i in range(1,N+1):
    neighbours=len(list(set(G[i])))
    if neighbours==A[i]:
        cnt+=1
print(cnt)

Submission status: Runtime Error

Solution code:

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

H = [0] + list(map(int,input().split()))

path = [0]
for i in range(1,N+1):
	path.append([])

for i in range(1,M+1):
	A, B = map(int,input().split())
	path[A].append(B)
	path[B].append(A)

count = 0

for i in range(1,N+1):
	if H[i] > max(H[j] for j in path[i]):
		count += 1
	
print(count)

Submission status: Runtime Error

Solution code:

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

H = [0] + list(map(int,input().split()))

path = {}
for i in range(1,N+1):
	path[i] = {}

for i in range(1,M+1):
	A, B = map(int,input().split())
	path[A].add(B)
	path[B].add(A)

count = 0

for i in range(1,N+1)
	if H[i] > max(H[j] for j in path[i]):
		count += 1
	
print(count)

Submission status: Runtime Error

Solution code:
from collections import defaultdict

def DFS(u,G,H,A,visited):
    visited[u]=True
    for v in G[u]:
        if not visited[v]:
            if H[u-1]>H[v-1]:
                A[u]+=1
            elif H[v-1]>H[u-1]:
                A[v]+=1
            DFS(v,G,H,A,visited)
def DFSUtil(G,H,N):
    visited=[False]*(N+1)
    A=[0]*(N+1)
    for u in G:
        if (not visited[u]):
            DFS(u,G,H,A,visited)
    return A
N,M=map(int,input().strip().split())
H=list(map(int,input().strip().split()))
G=defaultdict(list)

for i in range(M):
    u,v=map(int,input().strip().split())
    G[u].append(v)
    G[v].append(u)
A=DFSUtil(G,H,N)
cnt=0
for i in range(1,N+1):
    neighbours=len(list(set(G[i])))
    if neighbours==A[i]:
        cnt+=1
print(cnt)

Submission status: Runtime Error

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

print(ans)

Submission status: Runtime Error

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

print(ans)

Submission status: Runtime Error

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

print(ans)

Submission status: Runtime Error

Solution code:
total_tenb,total_load=map(int,input().split())

import copy
a=list(map(int,input().split()))
hight=copy.copy(a)
good_tenb=copy.copy(a)

  
def kuraberu(A,B):
  if hight[A-1]>hight[B-1]:
    good_tenb.append(height[A-1])
    good_tenb.pop(height[B-1])
  elif hight[A-1]<hight[B-1]:
    good_tenb.append(hight[B-1])
    good_tenb.pop(hight[A-1])
    
  
for h in range(total_load):
  A,B=map(int,input().split())
  kuraberu(A,B)
  
  
print(len(set(good_tenb)))

Submission status: Runtime Error

Solution code:
total_tenb,total_load=map(int,input().split())
hight=[]
good_tenb=[]
for i in range(total_tenb):
  a=int(input())
  hight.append(a)
  good_tenb.append(a)
  
def kuraberu(A,B):
  if hight[A]>hight[B]:
    good_tenb.append(height[A])
    good_tenb.pop(height[B])
  elif hight[A]<hight[B]:
    good_tenb.append(hight[B])
    good_tenb.pop(hight[A])
    
  
for h in range(total_load):
  A[h]=int(input())
  B[h]=int(input())
  kuraberu(A[h],B[h])
  
  
print(len(set(good_tenb)))

Submission status: Runtime Error

Solution code:
total_tenb,total_load=map(int,input().split())
hight=[]
good_tenb=[]
for i in range(total_tenb):
  a=int(input())
  hight.append(a)
  good_tenb.append(a)
  
def kuraberu(A,B):
  if hight[A]>hight[B]:
    good_tenb.append(height[A])
    good_tenb.del(height[B])
  elif hight[A]<hight[B]:
    good_tenb.append(hight[B])
    good_tenb.del(hight[A])
    
  
for h in range(total_load):
  A[h]=int(input())
  B[h]=int(input())
  kuraberu(A[h],B[h])
  
  
print(len(set(good_tenb)))

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
H = list(map(int, input().split()))
a = list(range(1,N+1))
for i in range(M):
  ai, bi = map(int, input().split())
  if H[ai-1] <= H[bi-1] :
    a.remove(ai)
  if H[ai-1] >= H[bi-1]:
    a.remove(bi)
print(len(a))

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
H = list(map(int, input().split()))
a = list(range(1,N+1))
for i in range(M):
  ai, bi = map(int, input().split())
  if H[ai-1] < H[bi-1] :
    a.remove(ai)
  else:
    a.remove(bi)
print(len(a))

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
H = list(map(int, input().split()))
a = list(range(1,N+1))
for i in range(M):
  ai, bi = map(int, input().split())
  if H[ai+1] < H[bi+1] :
    a.remove(ai)
  else:
    a.remove(bi)
print(len(a))

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
H = list(map(int, input().split()))
a = []
[a.append(i) for i in range(1,N+1)]
for i in range(M):
  ai, bi = map(int, input().split())
  if H[ai+1] < H[bi+1] :
    a.remove(ai)
  else:
    a.remove(bi)
print(len(a))

Submission status: Runtime Error

Solution code:
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

n, m = readmi()
l = readl()
p = defaultdict(lambda : defaultdict(int))

for i in range(m):
    a, b = readmi()
    p[a][b] = 1
    p[b][a] = 1

f = [0] * (n + 1)
count = 0
def dfs(a):
    flg = True
    global count
    for i in p[a]:
        if p[a][i] == 1:
            if f[i] == 0:
                f[i] = 1
                dfs(i)
            if l[a - 1] < l[i - 1]:
                flg = False
    if flg:
        count += 1
dfs(1)
print(count)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
H = list(map(int, input().split()))
a = []
[a.append(i) for i in range(1,N+1)]
for i in range(M):
  ai, bi = map(int, input().split())
  if ai < bi:
    a.remove(ai)
  else:
    a.remove(bi)
print(len(a))

Submission status: Runtime Error

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

def main():
    x = int(input())
    for i in range(-1000, 1000):
        for j in range(-1000, 1000):
            if x == i**5 - j**5:
                print(i, j)
                break
        else:
            continue
        break

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import copy

n, m = map(int, input().split())
h = list(map(int, input().split()))
l = []
for i range(m):
    a, b = map(int, input().split())
    l.append([a, b])

ll = [0]*n

for j in l:
    if h[j[0] - 1] > h[j[1] - 1]:
        ll[j[1] - 1] += 1
    elif h[j[0] - 1] == h[j[1] - 1]:
        ll[j[1] - 1] += 1
        ll[j[0] - 1] += 1
    else:
        ll[j[0] - 1] += 1

ans = 0

for k in ll:
    if k == 0:
        ans += 1
    else:
        ans += 0
    
print(ans)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
h = list(map(int, input().split()))
l = []
for i range(m):
    a, b = map(int, input().split())
    l.append([a, b])

ll = [0]*n

for j in l:
    if h[j[0] - 1] > h[j[1] - 1]:
        ll[j[1] - 1] += 1
    elif h[j[0] - 1] == h[j[1] - 1]:
        ll[j[1] - 1] += 1
        ll[j[0] - 1] += 1
    else:
        ll[j[0] - 1] += 1

ans = 0

for k in ll:
    if k == 0:
        ans += 1
    else:
        ans += 0
    
print(ans)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
h = list(map(int, input().split()))
l = []
for i range(m):
    a, b = map(int, input().split())
    l.append([a, b])

ll = [0]*n

for j in l:
    if h[j[0] - 1] > h[j[1] - 1]:
        ll[j[1] - 1] += 1
    elif h[j[0] - 1] > h[j[1] - 1]:
        ll[j[1] - 1] += 1
        ll[j[0] - 1] += 1
    else:
        ll[j[0] - 1] += 1

ans = 0

for k in ll:
    if k == 0:
        ans += 1
    else:
        ans += 0
    
print(ans)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
h = list(map(int, input().split()))
l = []
for i range (m):
    a, b = map(int, input().split())
    l.append([a, b])

ll = [0]*n

for j in l:
    if h[j[0] - 1] > h[j[1] - 1]:
        ll[j[1] - 1] += 1
    elif h[j[0] - 1] > h[j[1] - 1]:
        ll[j[1] - 1] += 1
        ll[j[0] - 1] += 1
    else:
        ll[j[0] - 1] += 1

ans = 0

for k in ll:
    if k == 0:
        ans += 1
    else:
        ans += 0
    
print(ans)

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
H=list(map(int,input().split()))
ABmap=[[] for i in range(N)]
count=0
for i in range(M):
    A,B=map(lambda x:x-1,map(int,input().split()))
    ABmap[A].append(H[B])
    ABmap[B].append(H[A])
        
for i in range(N):
    #print(ABmap[i])
    #print(ABmap.count(H[i]))
    if max(ABmap[i])<H[i]:
        count+=1
print(count)

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
H=list(map(int,input().split()))
ABmap=[[0 for i in range(N)] for i in range(N)]
count=0
for i in range(M):
    A,B=map(lambda x:x-1,map(int,input().split()))
    ABmap[A][B]=H[B]
    ABmap[B][A]=H[A]
    ABmap[A][A]=H[A]
    ABmap[B][B]=H[B]
    #print(ABmap[A])
    
for i in range(M):
    if max(ABmap[i])==H[i]:
        count+=1
print(count)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split(" "))
flag = [1 for i in range(M)]
height = list(map(int, input().split(" ")))
for i in range(M):
  a, b = map(int, input().split(" "))
  if height[a - 1] < height[b - 1]:
    flag[a - 1] = 0
  elif height[a - 1] > height[b - 1]:
    flag[b - 1] = 0
  else:
    flag[a - 1] = 0
    flag[b - 1] = 0
print(sum(flag))

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split(" "))
flag = [1 for i in range(M)]
height = list(map(int, input().split(" ")))
for i in range(M):
  a, b = map(int, input().split(" "))
  if height[a - 1] < height[b - 1]:
    flag[a - 1] = 0
  elif height[a - 1] > height[b - 1]:
    flag[b - 1] = 0
  else:
    flag[a - 1] = flag[b - 1] = 0
print(sum(flag))

Submission status: Runtime Error

Solution code:
n, m = map(int,input().split())
h = map(int,input().split())
for _ in range(m):
  a,b = map(int,input().split())
  for i in range(n):
    if a = n:
      if h[i] > h[b-1]:
        good += 1
    if b = n:
      if h[i] > h[a-1]:
        good += 1
print(good)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
hl=input().split()
shl=[int(x) for x in hl]
vl=set()
for i in range(m):
    a,b=map(int,input().split())
    if shl[a-1]>shl[b-1]:
        vl.add(b-1)
    elif shl[a-1]<shl[b-1]:
        vl.add(a-1)
    else:
        vl.add(a-1)
        vl.add(b-1)
    print(vl)
lshl=len(shl)
lvl=len(vl)
ans=lshl-lvl
print(ans)

Submission status: Runtime Error

Solution code:
def i():
    return int(input())
def i2():
    return map(int,input().split())
def s():
    return str(input())
def l():
    return list(input())
def intl():
    return list(int(k) for k in input().split())

n,m=i2()
h=intl()
cnt=0
score=0
l=[[] for i in range(n)]
for j in range(m):
	a,b=i2()
	l[a-1].append(b-1)
	l[b-1].append(a-1)
for j in range(n):
	for k in l[j]:
		if h[j]>h[k]:
			cnt+=1
			if cnt==len(l[j]):
				score+=1
	cnt=0
for i in range(m):
	if len(l[i])==0:
		score+=1
print(score)

Submission status: Runtime Error

Solution code:
def i():
    return int(input())
def i2():
    return map(int,input().split())
def s():
    return str(input())
def l():
    return list(input())
def intl():
    return list(int(k) for k in input().split())

n,m=i2()
h=intl()
cnt=0
score=0
l=[[] for i in range(n)]
for j in range(m):
	a,b=i2()
	l[a-1].append(b-1)
	l[b-1].append(a-1)
for j in range(n):
	for k in l[j]:
		if h[j]>k:
			cnt+=1
			if cnt==len(l[j]):
				score+=1
	cnt=0
for i in range(m):
	if len(l[i])==0:
		score+=1
print(score)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split(" "))
height = map(int, input().split(" "))
flag = [1 for i in renge(len(height))]
for i in range(M):
  a, b = map(int, input().split(" "))
  if height[a - 1] > height[b - 1]:
    flag[b - 1] = 0
  elif height[b - 1] > height[a - 1]:
    flag[a - 1] = 0
print(sum(flag))

Submission status: Runtime Error

Solution code:
    #include <bits/stdc++.h>
    using namespace std;
   int a[100010],b[100010],vis[100010],h[1000010];
    int main()
    {
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        cin>>h[i];
    }
    for(int i=1;i<=m;i++)
    {
        cin>>a[i]>>b[i];
    }
    for(int i=1;i<=m;i++)
    {

        //if(h[a[i]]==h[b[i]]){vis[a[i]]=-1,vis[b[i]]=-1;}
        if(h[a[i]]>h[b[i]]&&vis[a[i]]!=-1){vis[b[i]]=-1,vis[a[i]]=1;}
         if (h[b[i]]>h[a[i]]&&vis[b[i]]!=-1){vis[b[i]]=1,vis[a[i]]=-1;}
    }
    int c=0;
    for(int i=1;i<=n;i++)
        if(vis[i]==1||vis[a[i]]==0)c++;
     cout<<c<<endl;
     return 0;
    }

Submission status: Runtime Error

Solution code:
N,M=input().split()
A=input().split()
route=[]
for i in range(int(M)):
  a=input().split()
  route.append(a)
answer=1
count=0
for i in range(int(N)):
  for j in range(int(M)):
    
    if len([l for l in route[j] if int(l)!=i+1])==1:
      if A[i]>A[int(route[j][0])]:
        answer=1
      elif A[i]<A[int(route[j][0])]:
        answer=0
        break
      else:
          answer=1
  count+=answer
  
    
    
print(count)

Submission status: Runtime Error

Solution code:
N,M=input().split()
A=input().split()
route=[]
for i in range(int(M)):
  a=input().split()
  route.append(a)
answer=1
count=0
for i in range(int(N)):
  for j in range(int(M)):
    print([l for l in route[j] if int(l)!=i+1])
    if len([l for l in route[j] if int(l)!=i+1])==1:
      if A[i]>A[int(route[j][0])]:
        answer=1
      elif A[i]<A[int(route[j][0])]:
        answer=0
        break
      else:
          answer=1
  count+=answer
  print(count)
    
    
print(count)

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
H = list(map(int,input().split()))
W = [1 for i in range(N)]
for i in range(M):
    a,b = map(int,input().split())
    if H[a-1] >= H[b-1]:
        W[b-1] = 0
    if H[b-1] >= H[a]:
        W[a-1] = 0
ans = 0
for i in W:
    ans += i
print(ans)

Submission status: Runtime Error

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

ans = 0
for idx, aa in enumerate(edges):
	for a in aa:
		if Hs[idx] <= Hs[a]:
			break
		ans += 1
		break
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
h = list(map(int, input().split()))
l_n = [True] * n
for i in range(m):
    a, b = map(int, input().split())
    elif h[a-1] >= h[b-1]:
        l_n[b-1] = False
    elif h[a-1] <= h[b-1]:
        l_n[a-1] = False
print(sum(l_n))

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
h = list(map(int, input().split()))
l_n = [True] * n
for i in range(m):
    a, b = map(int, input().split())
    elif h[a-False] >= h[b-False]:
        l_n[b-False] = False
    elif h[a-False] <= h[b-False]:
        l_n[a-False] = False
print(sum(l_n))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
height = list(map(int,input().split()))
lower_list = []
for i in range(m):
    r = list(map(int,input().split()))
    if height[r[0]-1] > height[r[1]-1]:
        lower_list.append(r[1])
    elif height[r[0]-1] < height[r[1]-1]:
        lower_list.append(r[0],r[1])
    else:
        lower_list.append(r[0])
count = len(set(lower_list))
print(n-count)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
height = list(map(int,input().split()))
lower_list = []
for i in range(m):
    r = list(map(int,input().split()))
    if height[r[0]-1] > height[r[1]-1]:
        lower_list.append(r[1])
    elif:
        lower_list.append(r[0],r[1])
    else:
        lower_list.append(r[0])
count = len(set(lower_list))
print(n-count)

Submission status: Runtime Error

Solution code:
temp = input().split(" ")
N = int(temp[0])
M = int(temp[1])
H = input().split(" ")
good = [1] * N
for i in range(M):
    root = input().split(" ")
    a = int(root[0])-1
    b = int(root[1])-1
    if H[a]=>H[b]:
        good[b] = 0
    if H[a]<H[b]:
        good[a] = 0

print(sum(good))

Submission status: Runtime Error

Solution code:
if __name__ == "__main__":
  list_N_M = input().split(' ')
  N = int(list_N_M[0])
  M = int(list_N_M[1])
  
  list_str_H_all = input().split(' ')
  H = [0.0] * N
  for i in range(len(list_str_H_all)):
    H[i] = float(list_str_H_all[i])
  
  is_good_vp = [True] * N
  
  for _ in range(M):
    str_A_B = input().split(' ')
    A = int(str_A_B[0])
    B = int(str_A_B[1])
    
    if H[A-1] > H[B-1]:
      is_good_vp[B-1] = False
    elif H[B-1] > H[A-1]:
      is_good_vp[A-1] = False
    
  output = 0
  for i in rabge(N):
    if is_good_vp[i]:
      output += 1
      
  print(output)

Submission status: Runtime Error

Solution code:
if __name__ == "__main__":
  list_N_M = input().split(' ')
  N = int(list_N_M[0])
  M = int(list_N_M[1])
  
  list_str_H_all = input().split(' ')
  H = [0.0] * N
  for i in range(len(list_str_H_all)):
    H[i] = float(list_str_H_all[i])
  
  is_good_vp = [True] * N
  
  for _ in range(M):
    str_A_B = input().split(' ')
    A = int(str_A_B[0])
    B = int(str_A_B[1])
    
    if H[A-1] > H[B-1]:
      is_good_vp[B-1] = False
    elif H[B-1] > H[A-1]:
      is_good_vp[A-1] = False
    
  output = 0
  for i in N:
    if is_good_vp[i]:
      output += 1
      
  print(output)

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

ct=0
for j in range(N):
    if H[j]>[j]:
        ct+=1
print(ct)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
h=list(map,input().split())
x=[[] for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  x[a-1].append(b-1)
  x[b-1].append(a-1)
c=0
for i in range(n):
  f=1
  maxh=0
  for j in x[i]:
    maxh=max(maxh,h[j])
  if maxh>=h[i]:
    f=0
  c+=f
print(c)

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
H = list(map(int,input().split()))
XX = [set() for i in range(N)]
ans = 0
for i in range(M):
  A,B = map(int,input().split())
  XX[A-1].add(B)
  XX[B-1].add(A)
  
for i in range(N):
  for y in XX[i]:
    r = True
    if H[i]<=H[y]:
      r = False
      break
    if r:
      ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
H = list(map(int,input().split()))
XX = [set() for i in range(N)]
ans = 0
for i in range(M):
  A,B = map(int,input().split())
  XX[A-1].add(B)
  XX[B-1].add(A)
  
for i in range(N):
  for y in XX[i]:
    if H[i]<=H[y]:
	    break
    else:
    	ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
H = list(map(int,input().split()))
XX = [set() for i in range(N)]
ans = 0
for i in range(M):
  A,B = map(int,input().split())
  XX[A-1].add(B)
  XX[B-1].add(A)
  
for i in range(N):
  for y in XX[1]
  	if H[i]<=H[y]:
      break
    else:
      ans += 1
      
print(ans)

Submission status: Runtime Error

Solution code:
def main():
    n, m = map(int, input().split())
    wxyz = [list(map(int, input().split())) for _ in [0]*m]

    class unionfind():
        # size:要素数,tree：unionfind木
        def __init__(self, size):  # self,要素数
            self.size = size
            self.tree_root = list(range(self.size))
            self.tree_depth = [1]*self.size

        # rootを探す
        def root(self, index):
            temp_list = []
            temp = self.tree_root[index]
            while index != temp:
                temp_list.append(index)
                index = temp
                temp = self.tree_root[index]
            for i in temp_list:
                self.tree_root[i] = index
            return index

        # 結合
        def unite(self, index1, index2):
            r1 = self.root(index1)
            r2 = self.root(index2)
            if r1 != r2:
                d1, d2 = self.tree_depth[r1], self.tree_depth[r2]
                if d1 <= d2:
                    self.tree_root[r1] = r2
                    self.tree_depth[r2] = max(d1+1, d2)
                else:
                    self.tree_root[r2] = r1
                    self.tree_depth[r1] = max(d2+1, d1)

        # 同じか判定
        def same(self, index1, index2):
            r1 = self.root(index1)
            r2 = self.root(index2)
            return r1 == r2

        # 連結成分の個数
        def component(self):
            return len({self.root(i) for i in range(self.size)})

    u = unionfind(2*n)

    for w, x, y, z in wxyz:
        x -= 1
        y -= 1
        if w == 1:
            if z % 2 == 0:
                u.unite(x, y)
                u.unite(x+n, y+n)
            else:
                u.unite(x, y+n)
                u.unite(x+n, y)
        else:
            print(["NO", "YES"][u.same(x, y) or u.same(x+n, y+n)])


main()

Submission status: Runtime Error

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    import numpy as np
    from scipy.sparse import csgraph
    from scipy.sparse import csr_matrix

    N, M = map(int, input().split())
    H = np.array(list(map(int, input().split())))
    AB = np.array([list(map(int, input().split())) for i in range(M)])-1

    ab0 = list(AB[:, 0])
    ab1 = list(AB[:, 1])
    csr = csr_matrix(
        ([1]*(2*M), (ab0+ab1, ab1+ab0)), shape=(N, N)).toarray()

    count = 0
    for i, indices in enumerate(csr):
        if (indices == 0).all():
            count += 1
            continue
        if np.max(H[indices != 0]) < H[i]:
            count += 1

    print(count)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
#ABC166d
N, M = map(int,input().split())
H = list(map(int, input().split()))
count=[0]*M
A = [0]*M
B = [0]*M

for i in range(M):
    A[i], B[i] = map(int, input().split())

ans = [1]*N

for i in range(N):
    if H[A[i]-1] == H[B[i]-1]:
        ans[A[i]-1] = 0
        ans[B[i]-1] = 0
    elif H[A[i]-1] > H[B[i]-1]:
        ans[B[i]-1] = 0
    elif H[A[i]-1] < H[B[i]-1]:
        ans[A[i]-1] = 0
print(sum(ans))

Submission status: Runtime Error

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

judge = ["ok" for i in range(n)]

for i in range(m):
    a, b = [int(s) - 1 for i in input().split()]

    if high[a] < high[b]:
        judge[a] = "ng"
    elif high[a] > high[b]:
        judge[b] = "ng"
    else:
        judge[a] = "ng"
        judge[b] = "ng"

print(judge.count("ok"))