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())
s = list(map(int,input().split()))
a = []*m
b = []*m
ans = 0
for __ in range(m):
  _= list(map(int, input().split()))
  a.append(_)
  if s[_[0]-1] > s[_[1]-1]:
    b.append(_[0])
  elif s[_[0]-1] < s[_[1]-1]:
    b.append(_[1])
  else:
    b.append(0)
for i in range(n):
  count = 0
  for j in range(m):
    if i+1 in a[j]:
      count += 1
  if b.count(i+1) == count:
      ans += 1
      print(str(i+1) +" is good")
print(ans)

Submission status: Wrong Answer

Solution code:
import math
def fact(n):
    ans = 1
    for i in range(2, n+1):
        ans*= i
    return ans
def comb(n, c):
    return fact(n)//(fact(n-c)*c)

n, m  = map(int, input().split())
h = list(map(int, input().split()))
ans = 0
obs = {i:[] for i in range(1, n+1)}
for _ in range(m):
    a,b = map(int, input().split())
    obs[a].append(h[b-1])
    obs[b].append(h[a-1])
for i in range(1,n+1):
    obs[i] = sorted(obs[i], reverse= True)
for i in range(1,n+1):
    if(obs[i]==[]):
        ans+=1
    else:
        if(i > obs[i][0]):
            ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
import math
def fact(n):
    ans = 1
    for i in range(2, n+1):
        ans*= i
    return ans
def comb(n, c):
    return fact(n)//(fact(n-c)*c)

n, m  = map(int, input().split())
h = list(map(int, input().split()))
ans = 0
obs = {i:[] for i in range(1, n+1)}
for _ in range(m):
    a,b = map(int, input().split())
    obs[a].append(h[b-1])
    obs[b].append(h[a-1])
for _ in range(1,n+1):
    obs[_] = sorted(obs[_], reverse= True)
for i in range(1,n+1):
    if(obs[i]!=[]):
        if(len(obs[i])==1):
            ans+=1
        elif(i > obs[i][0]):
            ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
import math
def fact(n):
    ans = 1
    for i in range(2, n+1):
        ans*= i
    return ans
def comb(n, c):
    return fact(n)//(fact(n-c)*c)

n, m  = map(int, input().split())
h = list(map(int, input().split()))
ans = 0
obs = {i:[] for i in range(1, n+1)}
for _ in range(m):
    a,b = map(int, input().split())
    obs[a].append(h[b-1])
    obs[b].append(h[a-1])
for _ in range(1,n+1):
    obs[_] = sorted(obs[_], reverse= True)
for i in range(1,n+1):
    if(obs[i]):
        if(i > obs[i][0]):
            ans+=1
    else:
        ans+=1
print(ans)

Submission status: Wrong Answer

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

a = []
b = []
l = []
for i in ab:
  l.append(i[0])
  l.append(i[1])
  if h[i[0]-1] == h[i[1]-1]:
    a.append(h[i[0]-1])
  elif h[i[0]-1] > h[i[1]-1]:
    a.append(h[i[0]-1])
    b.append(h[i[1]-1])
  else:
    a.append(h[i[1]-1])
    b.append(h[i[0]-1])

num = n - len(list(set(l)))
#print(set(a)-set(b))
print(len(set(a)-set(b)) + num)

Submission status: Wrong Answer

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

a = []
b = []
l = []
for i in ab:
  l.append(i[0])
  l.append(i[1])
  if h[i[0]-1] > h[i[1]-1]:
    a.append(h[i[0]-1])
    b.append(h[i[1]-1])
  else:
    a.append(h[i[1]-1])
    b.append(h[i[0]-1])

num = n - len(list(set(l)))
#print(set(a)-set(b))
print(len(set(a)-set(b)) + num)

Submission status: Wrong Answer

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

a = []
b = []
l = []
for i in ab:
  l.append(i[0])
  l.append(i[1])
  if h[i[0]-1] == h[i[1]-1]:
    b.append(h[i[0]-1])
    b.append(h[i[1]-1])
  elif h[i[0]-1] > h[i[1]-1]:
    a.append(h[i[0]-1])
    b.append(h[i[1]-1])
  else:
    a.append(h[i[1]-1])
    b.append(h[i[0]-1])
num = len(h) - len(list(set(l)))
#print(set(a)-set(b))
print(len(set(a)-set(b)) + num)

Submission status: Wrong Answer

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

a = []
b = []
l = []
for i in ab:
  l.append(i[0])
  l.append(i[1])
  if h[i[0]-1] > h[i[1]-1]:
    a.append(h[i[0]-1])
    b.append(h[i[1]-1])
  else:
    a.append(h[i[1]-1])
    b.append(h[i[0]-1])

num = len(h) - len(list(set(l)))
print(len(set(a)-set(b)) + num)

Submission status: Wrong Answer

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

a = []
for i in ab:
  if h[i[0]-1] > h[i[1]-1]:
    a.append(h[i[0]-1])
  else:
    a.append(h[i[1]-1])
print(len(set(a)))

Submission status: Wrong Answer

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

a = []
for i in ab:
  if h[i[0]-1] > h[i[1]-1]:
    a.append(h[i[0]-1])
  else:
    a.append(h[i[1]-1])
print(len(set(a)))

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
H=list(map(int,input().split()))
d={i: H[i-1] for i in range(1,N+1)}
def compareObs(A,B):
    if A in d and B in d:
        if d[A]==d[B]:
            del d[A],d[B]
        elif d[A]>d[B]:
            del d[B]
        else:
            del d[A]
for i in range(M):
    A,B=map(int,input().split())
    compareObs(A,B)
print(len(d))

Submission status: Wrong Answer

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

ans = [0]*n
for i in range(m):
    a, b = map(int, input().split())
    if h[a-1] >= h[b-1]:
        ans[a-1] = 1
    if h[a-1] <= h[b-1]:
        ans[b-1] = 1

print(ans.count(1))

Submission status: Wrong Answer

Solution code:
ans = 0
n, m =map(int,input().split())
s = list(map(int,input().split()))
a = [list(map(int, input().split())) for _ in range(m)]
for i in range(1,n+1):
  l = []
  f = 0
  for _ in range(m):
    if i in a[_]:
      l += a[_]
      l.remove(i)
      if s[i-1] <= s[l[0]-1]:
        f += 1
        break
  if f ==0:
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
arr=[0]+list(map(int,input().split()))
g=[[] for _ in range(n+1)]
for _ in range(m):
  a,b=map(int,input().split())
  g[a].append(b)
  g[b].append(a)
ans=0
for v in range(1,n+1):
  for u in g[v]: #i番目の展望台から1本の道を通っていけるすべての展望台と高さを比較する
    if arr[u]>=arr[v]:
      break
    else: #i番目の展望台の高さが他のすべての展望台の高さより真に大きければ答えを1増やす
      ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
H = list(map(int, input().split()))
L = [list(map(int, input().split())) for i in range(m)]
P = []
for i in range(m):
  P = P + L[i]
P = list(set(P))
ans = 0
#print(P)

for i in range(len(P)):
  ANS = []
  for j in range(len(L)):
    if L[j][0] == i+1:
      ANS.append(H[L[j][1]-1])
    elif L[j][1] == i+1:
      ANS.append(H[L[j][0]-1])
    else:
      pass
    
#  print(ANS) 
  if ANS == [] or H[P[i]-1] <= max(ANS):
    pass
  else:
    ans += 1
    
ans += n-len(P)
    
print(ans)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
H = list(map(int, input().split()))
L = [list(map(int, input().split())) for i in range(m)]
P = []
for i in range(m):
  P = P + L[i]
P = list(set(P))
ans = 0
#print(P)

for i in range(len(P)):
  ANS = []
  for j in range(len(L)):
    if L[j][0] == i+1:
      ANS.append(H[L[j][1]-1])
    elif L[j][1] == i+1:
      ANS.append(H[L[j][0]-1])
    else:
      pass
    
#  print(ANS) 
  if ANS == [] or H[P[i]-1] <= max(ANS):
    pass
  else:
    ans += 1
    
for i in range(n):
  if i+1 not in P:
    ans+= 1
  else:
    pass
    
print(ans)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
H = list(map(int, input().split()))
L = [list(map(int, input().split())) for i in range(m)]
P = []
for i in range(m):
  P = P + L[i]
P = list(set(P))

#print(P)

ans = 0
for i in range(len(P)):
  ANS = []
  if (P[i] + 1 in P) and (P[i]-1 in P):
    ANS.append(H[P[i]])
    ANS.append(H[P[i]-2])
  elif P[i] + 1 in P:
    ANS.append(H[P[i]])
  elif P[i]-1 in P:
    ANS.append(H[P[i]-2])
  else:
    pass
#  print(ANS)
  
  if ANS == [] or H[P[i]-1] <= max(ANS):
    pass
  else:
    ans += 1

for i in range(n):
  if i+1 not in P:
    ans+= 1
print(ans)

Submission status: Wrong Answer

Solution code:
N,M = (int(x) for x in input().split())
H   = [int(x) for x in input().split()]
Way = [[] for I in range(N)]
for T in range(0,M):
    A,B = (int(x) for x in input().split())
    Way[A-1].append(B)
    Way[B-1].append(A)
    
Count = 0
for TT in range(0,N): 
    if [H[TT]]>[H[I-1] for I in Way[TT]]:
        Count = Count+1
print(Count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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)]
    ab_sorted = sorted(ab)
    ppp(n,m,h,ab_sorted)

Submission status: Wrong Answer

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

def peaks(n,m,h,ab):
    g = [0] * n
    path = [ [] for i in range(n)]
    #print(ab)
    for l,r in ab:
        path[l-1].append(r)
        path[r-1].append(l)

    #print(path)

    for i,p in enumerate(path):
        for j in p:
            #print(i,j,h[i],h[j-1])
            if h[i] >= h[j-1]:
                g[i] = 1
            else:
                g[i] = 0
                break
    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)]
    ab_sorted = sorted(ab)
    peaks(n,m,h,ab_sorted)

Submission status: Wrong Answer

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

def peaks(n,m,h,ab):
    g = [0] * n
    path = [ [i+1] for i in range(n)]
    #print(ab)
    for l,r in ab:
        path[l-1].append(r)
        path[r-1].append(l)

    #print(path)

    for i,p in enumerate(path):
        if h[i] >= max(p):
            g[i] = 1

    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)]
    ab_sorted = sorted(ab)
    peaks(n,m,h,ab_sorted)

Submission status: Wrong Answer

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

def peaks(n,m,h,ab):
    g = [0] * n
    path = [ [i+1] for i in range(n)]
    print(ab)
    for l,r in ab:
        path[l-1].append(r)
        path[r-1].append(l)

    print(path)

    for i,p in enumerate(path):
        if h[i] >= max(p):
            g[i] = 1

    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)]
    ab_sorted = sorted(ab)
    peaks(n,m,h,ab_sorted)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import copy

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

#print("p = {}".format(p))

height = copy.copy(h)
for i in p:
    index0 = i[0]
    index1 = i[1]
    if height[index0] < height[index1]:
        height[index0] = height[index1]
    elif height[index0] > height[index1]:
        height[index1] = height[index0]

#print("height = {}".format(height))

ret = 0
for i in range(n):
    if height[i] == h[i]:
        ret += 1

print("{}".format(ret))

Submission status: Wrong Answer

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-1] >= tenbo_height[tenbo]):
      all_lower = False
      break
  if (all_lower):
    good_tenbo += 1
    continue
    
print(good_tenbo)

Submission status: Wrong Answer

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

H=[0]                           #各丘の高さ(index1は文中の1)
for h in hs:
    H.append(int(h))


P=[[0]*1 for i in range(N+1)]   #各丘からの道 二次元配列 (index1は文中の1)
count=0
for p in range(len(P)):
    P[p][0]=p                   #P[][0] 各配列の要素1は自身の丘の数字
# print(P)

for m in range(M):
    pathfrom,pathto= map (int,input().split())
    P[pathfrom].append(H[pathto])
    P[pathto].append(H[pathfrom])
for i in range(1,len(P)):
    P[i][0]=H[i]
    if P[i][0]>max(P[i]) and len(P[i])>1:
        count+=1
print(count)

Submission status: Wrong Answer

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

H=[0]                           #各丘の高さ(index1は文中の1)
for h in hs:
    H.append(int(h))


P=[[0]*1 for i in range(N+1)]   #各丘からの道 二次元配列 (index1は文中の1)
count=0
for p in range(len(P)):
    P[p][0]=p                   #P[][0] 各配列の要素1は自身の丘の数字
# print(P)

for m in range(M):
    pathfrom,pathto= map (int,input().split())
    P[pathfrom].append(H[pathto])
    P[pathto].append(H[pathfrom])
for i in range(1,len(P)):
    P[i][0]=H[i]
    if P[i][0]>=max(P[i]) and len(P[i])>1:
        count+=1
print(count)

Submission status: Wrong Answer

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

H=[0]                           #各丘の高さ(index1は文中の1)
for h in hs:
    H.append(int(h))


P=[[0]*1 for i in range(N+1)]   #各丘からの道 二次元配列 (index1は文中の1)
count=0
for p in range(len(P)):
    P[p][0]=p                   #P[][0] 各配列の要素1は自身の丘の数字
# print(P)

for m in range(M):
    pathfrom,pathto= map (int,input().split())
    P[pathfrom].append(H[pathto])
    P[pathto].append(H[pathfrom])
print(P)
for i in range(1,len(P)):
    P[i][0]=H[i]
    if P[i][0]>=max(P[i]):
        count+=1
print(count)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
hs=input().split()
H=[0]                           #各丘の高さ(index1は文中の1)
P=[[0]*1 for i in range(N+1)]   #各丘からの道 
count=0
for p in range(len(P)):
    P[p][0]=p
# print(P)
for h in hs:
    H.append(int(h))
# print(H)                      #各丘の高さ()
for m in range(M):
    pathfrom,pathto= map (int,input().split())
    P[pathfrom].append(H[pathto])
    P[pathto].append(H[pathfrom])
for i in range(1,len(P)):
    P[i][0]=H[i]
    if P[i][0]>max(P[i]):
        count+=1
print(count)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
hs=input().split()
H=[0]                           #各丘の高さ(index1は文中の1)
P=[[0]*1 for i in range(N+1)]   #各丘からの道 
count=0
for p in range(len(P)):
    P[p][0]=p
# print(P)
for h in hs:
    H.append(int(h))
# print(H)                      #各丘の高さ()
for m in range(M):
    pathfrom,pathto= map (int,input().split())
    P[pathfrom].append(H[pathto])
    P[pathto].append(H[pathfrom])
for i in range(1,len(P)):
    P[i][0]=H[i]
    if P[i][0]>=max(P[i]):
        count+=1
print(count)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
hs=input().split()
H=[0]
P=[[0]*1 for i in range(N+1)]       #各丘からの道 
count=0
for p in range(len(P)):
    P[p][0]=p
# print(P)
for h in hs:
    H.append(int(h))
# print(H)                      #各丘の高さ()
for m in range(M):
    pathfrom,pathto= map (int,input().split())
    P[pathfrom].append(H[pathto])
    P[pathto].append(H[pathfrom])
for i in range(len(P)):
    P[i][0]=H[i]
    if P[i][0]>max(P[i]):
        count+=1
print(count)

Submission status: Wrong Answer

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

cnt = 0
for i in range(1, n+1):
    if len(g[i]) == 0:
        continue
    for j in g[i]:
        if h[j-1] >= h[i-1]:
            break
    else:
        cnt += 1

print(cnt)

Submission status: Wrong Answer

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

cnt = 0
for i in range(1, n+1):
    if len(g[i]) == 0:
        continue
    for j in g[i]:
        print(i, j)
        print(h[j-1], h[i-1])
        if h[j-1] >= h[i-1]:
            break
    else:
        cnt += 1

print(cnt)

Submission status: Wrong Answer

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

cnt = 0
for i in range(1, n+1):
    if len(g[i]) == 0:
        continue
    for j in g[i]:
        if h[j-1] > h[i-1]:
            break
    else:
        cnt += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
hs=input().split()
H=[0]
P=[[0]*1 for i in range(N+1)]       #各丘からの道 
count=0
for p in range(len(P)):
    P[p][0]=p
# print(P)
for h in hs:
    H.append(int(h))
# print(H)                      #各丘の高さ()
for m in range(M):
    pathfrom,pathto= map (int,input().split())
    P[pathfrom].append(H[pathto])
    P[pathto].append(H[pathfrom])
for i in range(len(P)):
    P[i][0]=H[i]
    if P[i][0]>=max(P[i]):
        count+=1
print(count)

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


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]:
      flag = 1
      continue
    elif i == B[m] and H[i-1]<=H[A[m]-1]:
      flag = 1
      continue
     
  if not flag:
    print(i)
    count += 1

print(count)

Submission status: Wrong Answer

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

for _ in range(m):
  b,c= map(int,input().split())
  if h[b-1]<=h[c-1]:
    a[b-1]=0
  else:
    a[c-1]=0
print(sum(a))

Submission status: Wrong Answer

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

for _ in range(m):
  b,c= map(int,input().split())
  if h[b-1]<h[c-1]:
    a[b-1]=0
  else:
    a[c-1]=0
print(sum(a))

Submission status: Wrong Answer

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

for _ in range(m):
  b,c= map(int,input().split())
  if h[b-1]>h[c-1]:
    a[b-1]=0
  else:
    a[c-1]=0
print(sum(a))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

def check(l, node):
    count = 0
    for i in l:
        if i == node:
            count+=1
    if count > 1:
        return True
    return False


def main():
    N, M = map(int,input().split(' '))
    H = list(map(int,input().split(' ')))
    H.insert(0,0)
    node = [[] for _ in range(N+1)]
    count = 0

    for _ in range(M):
        A, B = map(int,input().split(' '))
        node[A].append(B)
        node[B].append(A)

    for i in range(1,N+1):
        flag = False
        if len(node[i]) == 0:
            count+=1
            continue
        for n in node[i]:
            if check(node[i], n): continue
            if H[i] <= H[n]:
                break
            else:
                flag = True
        if flag:
            count += 1

    print(count)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:

def main():
    N, M = map(int,input().split(' '))
    H = list(map(int,input().split(' ')))
    H.insert(0,0)
    node = [[] for _ in range(N+1)]
    count = 0
    for _ in range(M):
        A, B = map(int,input().split(' '))
        node[A].append(B)
        node[B].append(A)

    for i in range(1,N+1):
        flag = False
        for n in node[i]:
            if H[i] <= H[n]:
                break
            else:
                flag = True
        if flag:
            count += 1

    print(count)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:

def main():
    N, M = map(int,input().split(' '))
    H = list(map(int,input().split(' ')))
    H.insert(0,0)
    node = [[] for _ in range(N+1)]
    count = 0
    for _ in range(M):
        A, B = map(int,input().split(' '))
        node[A].append(B)
        node[B].append(A)

    for i in range(1,N+1):
        flag = False
        for n in node[i]:
            if H[i] < H[n]:
                break
            else:
                flag = True
        if flag:
            count += 1

    print(count)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import collections

N, M = map(int,input().split())
Hl = list(map(int,input().split()))
l0 = [1]*N
Hd = dict(zip(Hl,l0))

for i in range(M):
    A, B = map(int,input().split())
    if A > B:
        Hd[B] = 0
    else:
        Hd[A] = 0

count = 0
for value in Hd.values():
    count += value

print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

x = [True] * N

for _ in range(M):
	a,b = map(int,input().split())
	if H[a - 1] >= H[b - 1]:
		x[a - 1] = False
	if H[b - 1] >= H[a - 1]:
		x[a - 1] = False
print(len([i for i in x if i == True]))

Submission status: Wrong Answer

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
    else:
        check[ab[i][1]-1] = 0
print(sum(check))

Submission status: Wrong Answer

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()))
print(h)
print(ab)
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
    else:
        check[ab[i][1]-1] = 0
print(sum(check))

Submission status: Wrong Answer

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]:
        tree_sub[b-1] = 0
    if tree[a-1] < tree[b-1]:
        tree_sub[a-1] = 0
print(len(tree_sub)-tree_sub.count(0))

Submission status: Wrong Answer

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]):
        tree_sub[b-1] = 0
    elif (tree[a-1] < tree[b-1]):
        tree_sub[a-1] = 0
    else:
        tree_sub[a-1] = 0
        tree_sub[b-1] = 0
print(len(tree_sub)-tree_sub.count(0))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for j in range(1,n+1):
  for k in ab[j]:
    if h[j] <= h[k]:
      break
    else:  
      count += 1
      
print(count)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
h = [0] + list(map(int, input().split()))
ab = [[] for _ in range(n+1)]
check = [False for _ in range(n+1)]
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(1,n+1):
  for k in ab[j]:
    if h[j] <= h[k]:
      check[k] = True
      
print(check.count(True))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
h = [0] + list(map(int, input().split()))
ab = [[] for _ in range(n+1)]
check = [False for _ in range(n+1)]
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(1,n+1):
  for k in ab[j]:
    if h[j] <= h[k]:
      check[j] = True
      
print(check.count(True))

Submission status: Wrong Answer

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: Wrong Answer

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
    else:
      check[j] = False

print(check.count(True))