Problem:


Score : 300 points

Problem Statement

There are N observatories in AtCoder Hill, called Obs. 1, Obs. 2, ..., Obs. N. The elevation of Obs. i is H_i.
There are also M roads, each connecting two different observatories. Road j connects Obs. A_j and Obs. B_j.

Obs. i is said to be good when its elevation is higher than those of all observatories that can be reached from Obs. i using just one road.
Note that Obs. i is also good when no observatory can be reached from Obs. i using just one road.

How many good observatories are there?

Constraints

2 \leq N \leq 10^5

1 \leq M \leq 10^5

1 \leq H_i \leq 10^9

1 \leq A_i,B_i \leq N

A_i \neq B_i

Multiple roads may connect the same pair of observatories.

All values in input are integers.

Input

Input is given from Standard Input in the following format:

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

Output

Print the number of good observatories.

Sample Input 1

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

Sample Output 1

2

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

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

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

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

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

Sample Input 2

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

Sample Output 2

3



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


Sample output:
2

Submission status: Wrong Answer

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


ans = [1]*n
for i in ab:
    if h[i[0]-1] <= h[i[1]-1]:
        ans[i[0]-1] = 0
    if h[i[0]-1] >= h[i[1]-1]:
        ans[i[0]-2] = 0

print(ans.count(1))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)

def main():
    N, M = map(int, input().split())
    H = list(map(int, input().split()))
    T = [0] * N
    for _ in range(M):
        A, B = map(int, input().split())
        x = max(H[A-1], H[B-1])
        T[A-1] = max(T[A-1], x)
        T[B-1] = max(T[B-1], x)
    print(len([1 for x in zip(T, H) if x[0] == x[1]]))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
H  = list(map(int, input().split()))
ans = []
count = 0
for i in range(M):
  A, B = map(int, input().split())
  if (A not in ans) and (B not in ans):
    count += 1
    ans.append(A)
    ans.append(B)
  elif A not in ans:
    ans.append(A)
  elif B not in ans:
    ans.append(B)
print(count)

Submission status: Wrong Answer

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

graph = [[] for _ in range(n)]

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

minus = 0

for i in range(n):
    height = h[i]
    if graph[i]:
        for j in graph[i]:
            if h[j] > height:
                minus += 1
                break
    else:
        minus += 1
        continue

print(n-minus)

Submission status: Wrong Answer

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

g = [[] for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)


d = [[0, -1]]
ans = 0
is_visit = [False] * N
def search(node, par):
    global is_visit
    global ans
    d = [[node, par]]
    while d:
        node, par = d.pop()
        is_visit[node] = True
        h = H[node]
        children = g[node]
        res = True
        for child in children:
            _h = H[child]
            res *= h > _h
            if not is_visit[child]:
                d.append([child, node])
        
        ans += res


for i in range(N):
    if not is_visit[i]:
        search(i, -1)

print(ans)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
h = list(map(int,input().split()))
g = [[] for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    g[a].append(h[b])
    g[b].append(h[a])
ans = 0
for i in range(n):
    if len(g[i]) == 0:
        ans +=1
        continue
      
    if h[i] >= max(g[i]):ans += 1
print(ans)

Submission status: Wrong Answer

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

print(sum(ans))

Submission status: Wrong Answer

Solution code:
N,M = list(map(int,input().split()))
higher = list(map(int,input().split()))
safety = [0] * (N+1)
for i in range(M):
    B = list(map(int,input().split()))
    if higher[B[0]-1] > higher[B[1]-1]:
        safety[B[1]] = 1
    else:
        safety[B[0]] = 1
print(sum(safety))

Submission status: Wrong Answer

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

h = []
for i in H:
    h.append(i)
for i in range(M):
    a, b = map(int, input().split())
    if h[a-1] <= H[b-1] and h[b-1] != -1:
        h[a-1] = -1
    if h[b-1] <= H[a-1] and h[b-1] != -1:
        h[b-1] = -1

ans = N
for i in h:
    if i == -1:
        ans -= 1

print(ans)

Submission status: Wrong Answer

Solution code:
#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
import math
import itertools
from collections import defaultdict
from collections import Counter
import numpy as np

import heapq

def bfs(c,nu,di,node,val):
    c[nu]=True
    di[val[nu]]+=1
    for each in node[nu]:
        if c[each]:
            continue
        di=bfs(c,each,di,node,val)
    return di





n,k=list(map(int,input().split()))
h=list(map(int,input().split()))
node=[i for i in h]
for _ in range(k):
    i,v=list(map(int,input().split()))
    i-=1
    v-=1
    node[i]=max(node[i],node[v])
    node[v]=max(node[i],node[v])


check=[False for _ in range(n)]
ans=0
for i in range(n):
    if node[i]==h[i]:
        ans+=1
print(ans)

Submission status: Wrong Answer

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

ans=0
for i in range(n):
    if max(g[i][:])==h[i]:
        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)]
load = [[] for _ in range(N)]
ans = 0

for a,b in AB:
  a-=1
  b-=1
  load[a].append(b)
  load[b].append(a)
  
for i,lis in enumerate(load):
  if len(lis)==N-1:
    ans+=1
  else:
    judge = True
    for j in lis:
      if H[i]<=H[j]:
        judge = False
        break
    if judge:
      ans+=1
      
print(ans)

Submission status: Wrong Answer

Solution code:
#coding: utf-8
#coding: utf-8
N, M = map(int, input().split())
H = list(map(int, input().split()))
d = {i:H[i-1] for i in range(1, N+1)}
for i in range(M):
    a, b = map(int, input().split())
    d[a] = max(d[a], H[b-1])
    d[b] = max(d[b], H[a-1])
ans = 0
# print(d.values())
for i in range(N):
    if d[i+1] == H[i]:
        ans += 1
print(ans)

Submission status: Wrong Answer

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

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


ans = [1] * N
H = list(map(int, input().split()))

for _ in range(M):
    A, B = map(int, input().split())
    A -= 1
    B -= 1
    if H[A] == H[B]:
        ans[A] = 0
        ans[B] = 0
    elif H[A] > H[B]:
        ans[B] = 0
        H[B] = H[A]
    else:
        ans[A] = 0
        H[A] = H[B]

print (sum(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
hl = list(map(int, input().split()))
ans = [0]*n

for i in range(m):
    a, b = map(int, input().split())
    if hl[a-1] < hl[b-1]:
        ans[a-1] = 1
    else:
        ans[b-1] = 1

print(ans.count(0))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
hhh = list(map(int, input().split()))
aabb = [list(map(int, input().split())) for _ in range(m)]
cnt = [0] * n
for i in range(m):
    if hhh[aabb[i][0] - 1] > hhh[aabb[i][1] - 1]:
        cnt[aabb[i][0] - 1] += 1
    else:
        cnt[aabb[i][1] - 1] += 1
print(cnt.count(0))

Submission status: Wrong Answer

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

A = [0 for _ in range(m)]
B = [0 for _ in range(m)]
C = [[0 for _ in range(n)] for _ in range(n)]

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

c = 0
for i in range(n):
    ma = h[i]
    for j in range(n):
        if(C[i][j] == 1):
            ma = max(h[i],h[j])
    if(ma == h[i]):c += 1
print(c)

Submission status: Wrong Answer

Solution code:
n,m=list(map(int,input().split()))
h=list(map(int,input().split()))
b=[[]for i in range(n)]
for i in range(m):
  a=list(map(lambda x:int(x)-1,input().split()))
  b[a[0]].append(a[1])
  b[a[1]].append(a[0])
s=0
for i in range(n):
  f=1
  for j in b[i]:
    if h[i]<=h[j]:
      f=0
      break
  if f:
    s+=1

Submission status: Wrong Answer

Solution code:

N, M = map(int, input().split())
h = [int(c) for c in input().split()]
dic = [[] for i in range(N)]
for i in range(M):
  a,b = map(int, input().split())
  dic[a-1] += [b-1]
  dic[b-1] += [a-1]

ls = sorted(list(range(N)),key=lambda x:h[x], reverse=True)
used = [False]*N
ans = 0
for c in ls:
  if not used[c]:
    ans += 1
  for p in dic[c]:
    used[p] = True
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
import math
import scipy as sp
import queue
import collections

MOD = 10 ** 9 + 7
INF = 10 ** 9

def main(kwargs):
    n = kwargs["n"]
    m = kwargs["m"]
    H = kwargs["H"]
    A = kwargs["A"]
    B = kwargs["B"]
    tmp = [1 for i in range(n)]

    for i in range(m):
        if H[A[i] - 1] >= H[B[i] - 1]:
            tmp[B[i] - 1] = 0

        elif H[A[i] - 1] <= H[B[i] - 1]:
            tmp[A[i] - 1] = 0

    res = sum(tmp)
    return res

if __name__ == "__main__":
    kwargs = {}

    cin = input().split()
    #kwargs["n"] = cin[0]
    #kwargs["n"], kwargs["k"] = cin
    #kwargs["n"] = [int(i) for i in cin][0]
    kwargs["n"], kwargs["m"] = [int(i) for i in cin]

    cin = input().split()
    #kwargs["n"] = cin[0]
    #kwargs["n"], kwargs["k"] = cin
    #kwargs["n"] = [int(i) for i in cin][0]
    kwargs["H"] = [int(i) for i in cin]

    kwargs["A"] = []
    kwargs["B"] = []
    for i in range(kwargs["m"]):
        cin = input().split()
        #a = cin[0]
        #a = cin
        #a = [int(i) for i in cin][0]
        a, b = [int(i) for i in cin]
        kwargs["A"].append(a)
        kwargs["B"].append(b)

    cout = main(kwargs)
    print(cout)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
H=list(map(int,input().split()))
roads = []
for i in range(M):
    roads.append(list(map(int,input().split())))
    
for road in roads:
    x = min(road[0],road[1])
    if x in H:
        H.remove(x)
    
print(len(H))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

N,M = inputIL()
H = inputIL()

graph = [[] for _ in range(N)]
for _ in range(M-1):
    u, v = inputIL()
    graph[u-1].append(v-1)
    graph[v-1].append(u-1)
    
ans = 0
for i in range(N):
  flag = 1
  h = H[i]
  if len(graph[i]) ==  0:
    pass
  else:
    for j in graph[i]:
       if H[j] >= h:
        flag = 0
        break
  ans += flag
  
print(ans)

Submission status: Wrong Answer

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

graph=[set() for _ in range(N+1)]
for _ in range(M):
  a,b=map(int,input().split())
  graph[a].add(b)
  graph[b].add(a)
#print(graph)

high_list=[0]*(N+1)
for i in range(1,N+1):
  if high_list[i]==-1:
    continue
  
  h=hlist[i-1]
  for s in graph[i]:
    if h<=s:
      high_list[i]=-1
    if h>=s:
      high_list[s]=-1  
  if high_list[i]==0:
    high_list[i]=1

answer=0
for h in high_list:
  if h==1:
    answer+=1

print(answer)

Submission status: Wrong Answer

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

for i in range(len(h)):
    tmph = h[i]
    flg = 1
    if arr[i]:
        for j in arr[i]:
            if tmph < j:
                flg = 0
                break
    else:
        continue
    if flg == 1:
        ans +=1
print(ans)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
H=list(map(int,input().split()))
L=[]
for i in range(m):
    a,b=map(int,input().split())
    if H[a-1]<H[b-1]:
        L.append(a-1)
    else:
        L.append(b-1)
print(len(H)-len(set(L)))

Submission status: Wrong Answer

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

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

c=[1]*n

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

  if h[a]>=h[b]:
    c[b]=c[b]-1
  else:
    c[a]=c[a]-1

#print(c)
cnt=0
for i in range(n):
  if c[i]==1:
    cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split(" "))
h = list(map(int,input().split(" ")))
high = []
low = []
better = 0
for i in range(m):
  a,b = map(int,input().split(" "))
  if h[a-1] > h[b-1]:
    high.append(a)
    low.append(b)
  else:
    high.append(b)
    low.append(a)
for h in set(high):
  if not h in set(low):
    better += 1
print(better)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

G = {}

for i in range(1, N+1):
    G[i] = []
for i in range(M):
    a, b = map(int, input().split())
    G[a].append(b)
    G[b].append(a)

ans = 0
for n, miti in G.items():
    f = True
    if len(miti)==0: f = False
    for m in miti:
        if H[n-1] < H[m-1]:
            f = False
            break
    if f: ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import math
import collections

def main():
    N, M = map(int, input().split())
    H = list(map(int, input().split()))

    ans = [1]*N

    for m in range(M):
        A, B = map(int, 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)
    print(sum(ans))
    return 0

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np

N, M = map(int, input().split())
H = [int(i) for i in input().split()]
X = np.ones(N, np.bool)
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if H[a] < H[b]:
        X[a] = False
    else:
        X[b] = False
print(np.count_nonzero(X))

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
h = list(map(int,input().split()))
g = [[] for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    g[a].append(h[b])
    g[b].append(h[a])
ans = 0
for i in range(n):
    if len(g[i]) == 0:continue
    if h[i] >= max(g[i]):ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
[n,m] = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]
table = [[0]*n for i in range(n)]
ls = [1] * n
for i in range(m):
    [a,b] = [int(i)-1 for i in input().split()]
    if h[a] < h[b]:
        ls[a] = 0
    else:
        ls[b] = 0
print(sum(ls))
#print(ls)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n,m=mii()

arr=limii()

mat=[1]*n
for i in range(m):
    a,b=mii()
    if arr[a-1] < arr[b-1]:
        mat[a-1] =0
    else:
        mat[b-1] =0
print(sum(mat))

Submission status: Wrong Answer

Solution code:
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def resolve():
    N, M = lr()
    H = lr()
    road = [-1]*N
    for i in range(M):
        a, b = lr()
        mab = max(H[a-1], H[b-1])
        road[a-1] = max(mab, road[a-1])
        road[b-1] = max(mab, road[b-1])
    ans = 0
    for i in range(N):
        if road[i] == H[i] or road[i] == -1:
            ans += 1
    print(ans)
resolve()

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)]
graph = [H[i] for i in range(N)]
for a, b in ab:
  a -= 1
  b -= 1
  graph[a] = max(graph[a], graph[b])
  graph[b] = max(graph[b], graph[a])

ans = 0
for v in range(N):
  if graph[v] == H[v]:
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n,m = list(map(int,input().split()))

h = list(map(int,input().split()))
ab = [list(map(int,input().split())) for i in range(m)]


bad_tenbo_list = [0] * (n)
for a,b in ab:
    if h[a-1] > h[b-1]:
        bad_tenbo_list[b-1]=1
    else:
        bad_tenbo_list[a-1]=1

print(n-sum(bad_tenbo_list))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
n, m = map(int, input().split())
H = list(map(int, input().split()))
edges = [[] for _ in range(n)]
for _ in range(m):
    a, b = list(map(lambda x: int(x)-1, input().split()))
    edges[a].append(b)
    edges[b].append(a)


ans = [0]*n


def dfs(v, parent):
    if visited[v]:
        return 0
    visited[v] = 1
    # hight = H[v]
    if not edges[v]:
        ans[v] = 1
    for v2 in edges[v]:
        if v2 == parent:
            continue
        dfs(v2, v)
        if H[v] <= H[v2]:
            break
    else:
        ans[v] = 1


visited = [0]*n

for v in range(n):
    if visited[v]:
        continue
    dfs(v, -1)

print(sum(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 0
for i in t:
    if i != 0:
        ans += 1
print(ans)

Submission status: Wrong Answer

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



ans = [1] * N

for l in range(M):
    if H[A[l][0]-1] >= H[A[l][1]-1]:
        ans[A[l][1]-1] = 0
    else:
         ans[A[l][0]-1] = 0

print(sum(ans))

Submission status: Wrong Answer

Solution code:
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())  

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

uf = UnionFind( N + 1 )

for i in range( M ):
  a, b = map( int, input().split() )
  uf.union( a, b )

print( uf.group_count() )

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 i in range(M)]
hasi=[0]*N
ans=N
for i in range(M):
    if H[AB[i][0]-1]>H[AB[i][1]-1]:
        hasi[AB[i][1]-1]+=1
    elif H[AB[i][0]-1]<H[AB[i][1]-1]:
        hasi[AB[i][0]-1]+=1
    else:
        hasi[AB[i][0]-1]+=1
        hasi[AB[i][1]-1]+=1
print(ans-hasi.count(0))

Submission status: Wrong Answer

Solution code:
#template
def inputlist(): return [int(k) for k in input().split()]
#template
N,M = inputlist()
H = inputlist()
graph = [[] for _ in range(N)]
print(graph)

for i in range(M):
    A,B = inputlist()
    A -=1
    B -=1
    graph[A].append(B)
    graph[B].append(A)
ans = 0
for i in range(N):
    h = H[i]
    k = 0
    for j in graph[i]:
        k = max(k,H[j])
    if h > k:
        ans +=1
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

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

ans=[True for _ in range(n)]

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

print(ans.count(True))

Submission status: Wrong Answer

Solution code:
n, m = map(int,input().split())
graph = {i:[] for i in range(n)}
H = list(map(int,input().split()))
for _ in range(m):
  a,b = map(int,input().split())
  a, b = a-1, b-1
  
  if H[a]<H[b]:
    graph[a].append(b)
  elif H[b]>H[a]:
    graph[b].append(a)
  else:
    graph[a].append(b)
    graph[b].append(a)
    
ans = 0

for i in range(n):
  if len(graph[i]) ==0:
    ans += 1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

l = [1] * N

for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if H[a] >= H[b]:
        l[b] = 0
    if a <= b:
        l[a] = 0

print(sum(l))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**9)


def unite(par, i, j):
    j = get_par(par, j)
    par[j] = get_par(par, i)

def get_par(par, p):
    while par[p] != p:
        p = par[p]
    return par[p]

def resolve():
    n,m=map(int, input().split())
    h = [0] + list(map(int, input().split()))
    good = [h[i] for i in range(n+1)]
    par = [i for i in range(n+1)]

    for i in range(m):
        a,b = map(int, input().split())
        aa = get_par(par, a)
        bb = get_par(par, b)
        if aa == bb:
            continue
        # unite
        if good[aa] > good[bb]:
            par[bb] = aa
            good[bb] = good[aa]
        else:
            par[aa] = bb
            good[aa] += good[bb]

    print(len(set(par))-1)

if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def resolve():
    N, M = lr()
    H = lr()
    road = [-1]*N
    for i in range(M):
        a, b = lr()
        mab = max(H[a-1], H[b-1])
        road[a-1] = max(mab, road[a-1])
        road[b-1] = max(mab, road[b-1])
    ans = 0
    for i in range(N):
        if road[i] == H[i]:
            ans += 1
    print(ans)
resolve()

Submission status: Wrong Answer

Solution code:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1

"""

import collections
import itertools
import operator


class UnionFind:
    def __init__(self, x):
        class KeyDict(dict):
            def __missing__(self, key):
                self[key] = key
                return key

        self.parent = KeyDict()
        self.rank = collections.defaultdict(int)
        self.size = collections.defaultdict(lambda: 1)
        if x is not None:
            for elem in range(x+1):
                _, _, _ = self.parent[elem], self.rank[elem],self.size[elem]

    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if not self.are_same(x,y):
            xx = self.size[x]
            yy = self.size[y]
            if self.rank[x] < self.rank[y]:
                self.parent[x] = y
                self.size[y] += xx
            else:
                self.parent[y] = x
                self.size[x] += yy
        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1

    def Size(self,x):
        return self.size[self.find(x)]

    def are_same(self, x, y):
        '''print(x,y,self.find(x),self.find(y),self.find(x) == self.find(y))'''
        return self.find(x) == self.find(y)

    def grouper(self):
        roots = [(x, self.find(x_par)) for x, x_par in self.parent.items()]
        root = operator.itemgetter(1)
        for _, group in itertools.groupby(sorted(roots, key=root), root):
            yield [x for x, _ in group]

n,k = m()

h = l()

po = [1 for i in range(n)]

for i in range(k):
    a,b = m()
    if a > b:
        po[b-1] = 0
    elif a == b:
        po[a-1] = 0
    else:
        po[a-1] = 0
co = 0

for i in range(n):
    if po[i] == 1:
        co += 1



print(co)