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:
#ABC166
N,M=map(int,input().split())
H =list(map(int,input().split()))  #展望台の標高
A = list(range(N))
for i in range(M):
    a, b = map(int, input().split())
    if H[a-1] > H[b-1]:
        A[b-1] = 0
    elif H[a-1] < H[b-1]:
        A[a-1] = 0
    else:
        A[a-1] = 0
        A[b-1] = 0
print(N-A.count(0))

Submission status: Wrong Answer

Solution code:
#ABC166
N,M=map(int,input().split())
H =list(map(int,input().split()))  #展望台の標高
A = list(range(N))
for i in range(M):
    a, b = map(int, input().split())
    if H[a-1]>H[b-1]:
        A[b-1] = 0
    elif H[a-1]<H[b-1]:
        A[a-1] = 0
    else:
        A[a-1] = 0
        A[b-1] = 0

print(N-A.count(0))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

root = [0] * N

for _ in range(M):
    A, B = map(int, input().split())
    root[A-1] = max(H[B-1], root[B-1])
    root[B-1] = max(H[A-1], root[A-1])
    if H[A-1] == H[B-1]:
        root[A-1] = -100
        root[B-1] = -100

for i in range(N):
    if root[i] == H[i]:
        ans += 1
    elif root[i] == 0:
        ans += 1

print(ans)

Submission status: Wrong Answer

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

root = []
for i in range(N):
    root.append([H[i]])

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

for i in range(N):
    num = max(root[i])
    if num == H[i]:
        ans += 1
    if root[i].count(num) != 1:
        ans -= 1

print(ans)

Submission status: Wrong Answer

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

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

place = [True]*n

for i in range(m):
    a,b = ab[i][0],ab[i][1]
    if h[a-1] < h[b-1]:
        place[a-1] = False
    else:
        place[b-1] = False

print(place.count(True))

Submission status: Wrong Answer

Solution code:
from collections import deque

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

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

d = deque()
d.append(1)

while d:
 v = d.popleft()
 cnt=1
 for i in graph[v]:
   if h[v-1] <= h[i-1]:
     cnt=0
   d.append(i)
 if cnt==0:
     ans-=1

print(ans)

Submission status: Wrong Answer

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

for i in range(m):
    ab.append([int(s) for s in input().split()])

h2 = []
for p in ab:
    if h[p[0] - 1] < h[p[1] - 1]:
        h2.append(p[0] - 1)
    if h[p[0] - 1] == h[p[1] - 1]:
        h2.append(p[1] - 1)

print(len(h) - len(list(set(h2))))

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':

    #隣接リスト(graph)
    n,m = map(int,input().split())
    H = [int(h) for h in input().split()]

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

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


    #このリストから相手との関係を調べてよい展望台かどうか調べる？
    good = 0
    for i,g in enumerate(graph):
        moto = H[i]
        flg = True
        for saki in g:
            if moto > saki:
                flg = False
                break
        if flg:
            good += 1
    print(good)

Submission status: Wrong Answer

Solution code:
def main():
    import collections
    n, m = map(int, input().split())
    hs = list(map(int, input().split()))
    nmap = [0] * n
    cnt = 0

    for j in range(m):
        v = input().split()
        v0 = int(v[0]) - 1
        v1 = int(v[1]) - 1
        if hs[v0] < hs[v1]:
            nmap[v0] += 1
        elif hs[v0] == hs[v1]:
            nmap[v0] += 1
            nmap[v1] += 1
        # else:
        #     nmap[v1] += 1
    # print(nmap)
    for i in nmap:
        if i == 0:
            cnt += 1
    return cnt


if __name__ == '__main__':
    print(main())

Submission status: Wrong Answer

Solution code:
def main():
    import collections
    n, m = map(int, input().split())
    hs = list(map(int, input().split()))
    nmap = [0] * n
    cnt = 0

    for j in range(m):
        v = input().split()
        v0 = int(v[0]) - 1
        v1 = int(v[1]) - 1
        if hs[v0] < hs[v1]:
            nmap[v0] += 1
        elif hs[v0] == hs[v1]:
            nmap[v0] += 1
            nmap[v1] += 1
        # else:
        #     nmap[v1] += 1
    print(nmap)
    for i in nmap:
        if i == 0:
            cnt += 1
    return cnt


if __name__ == '__main__':
    print(main())

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=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[a-1] *= 1 
    ans[b-1] *= 0
  elif H[a-1]<=H[b-1]:
    ans[a-1] *= 0
    ans[b-1] *= 1
print(sum(ans))

Submission status: Wrong Answer

Solution code:
def main():
    import collections
    n, m = map(int, input().split())
    hs = [int(v) for v in input().split()]
    nmap = collections.defaultdict(list)

    for i in range(1, n + 1):
        nmap[i] = []

    for j in range(m):
        pair = [int(v) for v in input().split()]
        nmap[pair[0]] += [pair[1]]
        nmap[pair[1]] += [pair[0]]

    cnt = 0
    for key in nmap:
        nmap[key] = list(set(nmap[key]))
        if all(t < key for t in nmap[key]):
            cnt += 1
        if len(nmap[key]) == 0:
            cnt += 1
    return cnt


if __name__ == '__main__':
    print(main())

Submission status: Wrong Answer

Solution code:
def main():
    import collections
    n, m = map(int, input().split())
    hs = [int(v) for v in input().split()]
    nmap = collections.defaultdict(list)
    for i in range(1, n + 1):
        nmap[i] = []
    for j in range(m):
        pair = [int(v) for v in input().split()]
        nmap[pair[0]] += [pair[1]]
        nmap[pair[1]] += [pair[0]]
    cnt = 0
    for key in nmap:
        if all(t < key for t in nmap[key]):
            cnt += 1
        if len(nmap[key]) == 0:
            cnt += 1
    return cnt


if __name__ == '__main__':
    print(main())

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 i in range(1, n + 1):
    for j in g[i]:
        if arr[j] >= arr[i]:
            break
        else:
            ans += 1

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

tmp = [0]*N

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

    if H[a-1] > H[b-1]:
        tmp[b-1] = 1
    elif H[a-1] < H[b-1]:
        tmp[a-1] = 1
    else:
        tmp[a-1] = 1
        tmp[b-1] = 1

print(sum(tmp))

Submission status: Wrong Answer

Solution code:
from collections import deque
n,m = map(int,input().split())
h=list(map(int,input().split()))
g = [[] for _ in range(n)]
for _ in range(m):
    a,b = map(int,input().split())
    a-=1
    b-=1
    g[a].append(b)
    g[b].append(a)
ans=0
for j in range(n):
    for i in g[j]:
        if h[j]<=h[i]:
            break
    else:
        print(j)
        ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
H = list(map(int, input().split()))
AB = [sorted(list(map(int,input().split())))for i in range(M)]
AB.sort()
good = [True]*N
j = 0
for i in range(N):
    if not good[i]:
        continue
    while j < M:
        a,b = AB[j]
        if a+1 == i:
            if H[i] > H[b-1]:
                good[b-1] = False
            else:
                good[i] = False
            j +=1
        else:
            break
#print(good)
print(good.count(True))

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
H = list(map(int, input().split()))
AB = [sorted(list(map(int,input().split())))for i in range(M)]
AB.sort()
good = [True]*N
j = 0
for i in range(N):
    if not good[i]:
        continue
    while j < M:
        a,b = AB[j]
        if a == i-1:
            if H[i] > H[b-1]:
                good[b-1] = False
            else:
                good[i] = False
            j +=1
        else:
            break
#print(good)
print(good.count(True))

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
H = list(map(int, input().split()))
AB = [sorted(list(map(int,input().split())))for i in range(M)]
AB.sort()
good = [True]*N
for i in range(N):
    if not good[i]:
        continue
    for a,b in AB:
        if a == i:
            if H[i] > H[b-1]:
                good[b-1] = False
            else:
                good[i] = False
                break
print(good.count(True))

Submission status: Wrong Answer

Solution code:
# nは展望台の数　mは道の数
n,m = map(int,input().split())
high = list(map(int,input().split()))

deck = list(range(1,n+1))
a = []

for x in range(m):
    b = list(map(int,input().split()))
    a.append(b)

for y in a:
    high1 = high[y[0]-1]
    high2 = high[y[1]-1]
    if high1 >= high2:
        try:
            deck.remove(y[1])
        except :
            pass

    elif high1 == high2:
        try:
            deck.remove(y[0])
        except:
            pass
        try:
            deck.remove(y[1])
        except :
            pass
    else:
        try:
            deck.remove(y[0])
        except :
            pass

print(len(deck))

Submission status: Wrong Answer

Solution code:
n_m=list(map(int, input().split()))
h=list(map(int, input().split()))
roads=[None for i in range(n_m[1])]
count=0
for i in range(n_m[1]):
    a_b=list(map(int, input().split()))
    roads[i]=a_b
for i in range(n_m[0]):
    flag = 1
    height=h[i]
    for j in roads:
        if(j.count(i+1)>0):
           higher=max(h[j[0]-1],h[j[1]-1])
           if(higher!=h[i]):
            flag=0
            break
    if(flag==1):
        count+=1
for i in roads:
    if(roads.count(i)>1):
        count-=(roads.count(i))-(roads.count(i)-1)
print(count)

Submission status: Wrong Answer

Solution code:
n_m=list(map(int, input().split()))
h=list(map(int, input().split()))
roads=[None for i in range(n_m[1])]
count=0
for i in range(n_m[1]):
    a_b=list(map(int, input().split()))
    roads[i]=a_b
for i in range(n_m[0]):
    flag = 1
    height=h[i]
    for j in roads:
        if(j.count(i+1)>0):
           higher=max(h[j[0]-1],h[j[1]-1])
           if(higher!=h[i]):
            flag=0
            break
    if(flag==1):
        count+=1
for i in roads:
    if(roads.count(i)>1):
        count-=(roads.count(i))+(roads.count(i)-1)
print(count)

Submission status: Wrong Answer

Solution code:
n_m=list(map(int, input().split()))
h=list(map(int, input().split()))
roads=[None for i in range(n_m[1])]
count=0
for i in range(n_m[1]):
    a_b=list(map(int, input().split()))
    roads[i]=a_b
for i in range(n_m[0]):
    flag = 1
    height=h[i]
    for j in roads:
        if(j.count(i+1)>0):
           higher=max(h[j[0]-1],h[j[1]-1])
           if(higher!=h[i]):
            flag=0
            break
    if(flag==1):
        count+=1
for i in roads:
    if(roads.count(i)>1):
        count-=(roads.count(i))+1
print(count)

Submission status: Wrong Answer

Solution code:
n_m=list(map(int, input().split()))
h=list(map(int, input().split()))
roads=[None for i in range(n_m[1])]
count=0
for i in range(n_m[1]):
    a_b=list(map(int, input().split()))
    roads[i]=a_b
for i in range(n_m[0]):
    flag = 1
    height=h[i]
    for j in roads:
        if(j.count(i+1)>0):
           higher=max(h[j[0]-1],h[j[1]-1])
           if(higher!=h[i]):
            flag=0
            break
    if(flag==1):
        count+=1
for i in roads:
    if(roads.count(i)>1):
        count-=(roads.count(i)-1)
print(count)

Submission status: Wrong Answer

Solution code:
n_m=list(map(int, input().split()))
h=list(map(int, input().split()))
roads=[None for i in range(n_m[1])]
count=0
for i in range(n_m[1]):
    a_b=list(map(int, input().split()))
    roads[i]=a_b
for i in range(n_m[0]):
    flag = 1
    height=h[i]
    for j in roads:
        if(j.count(i+1)>0):
           higher=max(h[j[0]-1],h[j[1]-1])
           if(higher!=h[i]):
            flag=0
            break
        if(roads.count(j)>1):
            roads.pop(roads.index(j))
    if(flag==1):
        count+=1
print(count)

Submission status: Wrong Answer

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

N, M = list(map(int, input().split()))
h_list = list(map(int, input().split()))
h_dict = {i + 1: h for i, h in enumerate(h_list)}
h_set = set(h_list)
no_list = []

for _ in range(M):
    a, b = list(map(int, input().split()))
    if h_dict[a] == h_dict[b]:
        no_list.append(a)
        no_list.append(b)
    elif h_dict[a] > h_dict[b]:
        no_list.append(b)
    else:
        no_list.append(a)

no_set = set(no_list)
ans = len(h_set - no_set)

print(ans)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
length = list(map(int, input().split()))
sorted_index = sorted(range(1,len(length)+1), key = lambda x: -length[x-1])
connected_list = [[] for _ in range(n+1)]
good = [sorted_index[0]]

for _ in range(m):
    a, b = map(int, input().split())
    connected_list[a].append(b)
    connected_list[b].append(a)

for z, i in enumerate(sorted_index[1:]):
    if len(set(connected_list[i]) & set(good)) >= 1:
        continue
    elif z == n-2 and len(connected_list)>=1:
        continue
    else:
        good.append(i)
            
print(len(good))

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
h = list(map(int,input().split()))
l = list({i} for i in range(n+1))
for i in range(m):
    a,b = map(int,input().split())
    l[a].add(b)
    l[b].add(a)

for i in range(len(l)):
    l[i] = list(l[i])
good = set()
for i in range(1,len(l)):
    for j in range(len(l[i])):
        if h[l[i][j]-1] < h[i-1] or len(l[i])==1:
            good.add(i)
print(len(good))

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
h = list(map(int,input().split()))
l = list({i} for i in range(n+1))
for i in range(m):
    a,b = map(int,input().split())
    l[a].add(b)
    l[b].add(a)

for i in range(len(l)):
    l[i] = list(l[i])
good = set()
for i in range(1,len(l)):
    for j in range(len(l[i])):
        if h[l[i][j]-1] < h[i-1] or len(l[i])==1:
            good.add(h[i-1])
print(len(good))

Submission status: Wrong Answer

Solution code:
[N, M] = [int(i) for i in input().split()]
H = [int(i) for i in input().split()]
dic = {}
for i in range(M):
    [a, b] = [int(i) for i in input().split()]
    if a in dic:
        dic[a].append(b)
    else:
        dic[a] = [b]
    if b in dic:
        dic[b].append(a)
    else:
        dic[b] = [a]

ans = 0
for i in range(1, N+1):
    s = int(H[i-1])
    t = 0
    if i in dic:
        for j in range(len(dic[i])):
            if s <= H[int(dic[i][j])-1]:
                t += 1
            break
        if t == 0:
            ans += 1
    else:
        ans += 1

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
h=list(map(int,input().split()))
s=set()
for i in range(m):
  a,b=map(int,input().split())
  if h[a-1]<h[b-1]:
    s.add(a)
  else:
    s.add(b)

print(n-len(s))

Submission status: Wrong Answer

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

g = [[] for _ in range(n)]
for _ in range(m):
  a,b = map(int,input().split())
  g[a-1].append(b-1)
  g[b-1].append(a-1)
print(g)

cnt = n
for i in range(n):
  for j in g[i]:
    if h[i] <= h[j]:
      cnt -= 1
      break
print(cnt)

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())
c=list(map(int,input().split()))
f=[]
g=[]
for i in range(b):
    d,e=map(int,input().split())
    f.append(d)
    if(e not in f):
        g.append(e)
h=set(g)
print(len(h))

Submission status: Wrong Answer

Solution code:
N, M = [int(n) for n in input().split()]
H = [int(n) for n in input().split()]
visited = [0] * N
for i in range(M):
    a, b = [int(n)-1 for n in input().split()]
    if visited[a]<0 and visited[b]<0:
        continue
    if H[a] > H[b]:
        visited[b] = -1
        visited[a] = 1
    elif H[a] < H[b]:
        visited[a] = -1
        visited[b] = 1
    else:
        visited[a] = -1
        visited[b] = -1
print(visited.count(0)+visited.count(1))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(1000000000)

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

p = [i for i in range(N)]

def find(x):
    if p[x] == x:
        return p[x]
    else:
        p[x] = find(p[x])
        return p[x]

def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:return
    p[x] = y
    return

for query in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    unite(a, b)

print(len(set(p)))

Submission status: Wrong Answer

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

p = [i for i in range(N)]

def find(x):
    if p[x] == x:
        return p[x]
    else:
        p[x] = find(p[x])
        return p[x]

def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:return
    p[x] = y
    return

for query in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    unite(a, b)

print(len(set(p)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def resolve():
    N, M = list(map(int, input().split()))
    origH = list(map(int, input().split()))
    import copy
    H = copy.deepcopy(origH)
    AB = [list(map(int, input().split())) for _ in range(M)]
    for a, b in AB:
        a, b = a-1, b-1
        H[a] = max(H[a], H[b])
        H[b] = max(H[a], H[b])
    cnt = 0
    for i in range(N):
        if H[i] == origH[i]:
            cnt += 1
    print(cnt)


if '__main__' == __name__:
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    N, M = list(map(int, input().split()))
    origH = list(map(int, input().split()))
    import copy
    H = copy.deepcopy(origH)
    AB = [list(map(int, input().split())) for _ in range(M)]
    for a, b in AB:
        a, b = a-1, b-1
        if H[a] < H[b]:
            H[a] = H[b]
        else:
            H[b] = H[a]
    cnt = 0
    for i in range(N):
        if H[i] == origH[i]:
            cnt += 1
    print(cnt)


if '__main__' == __name__:
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    N, M = list(map(int, input().split()))
    H = list(map(int, input().split()))
    AB = [list(map(int, input().split())) for _ in range(M)]
    good = [True for _ in range(N)]
    for a, b in AB:
        a, b = a-1, b-1
        if H[a] < H[b]:
            good[a] = False
        else:
            good[b] = False
    cnt = 0
    for g in good:
        if g:
            cnt += 1
    print(cnt)


if '__main__' == __name__:
    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 i in range(m)]

xmax=set()
xmin=set()
ans=0

for i in range(m):
    xmax.add(max(ab[i][0],ab[i][1]))

for i in range(m):
    xmin.add(min(ab[i][0],ab[i][1]))
    xmax.discard(min(ab[i][0],ab[i][1]))

for j in h:
    if j not in xmax:
        if j not in xmin:
            ans+=1

print(len(xmax)+ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
N, M = map(int,input().split())
C = np.zeros(N)
d = 0
H = list(map(int,input().split()))
for i in range(M):
  A, B = map(int,input().split())
  if H[A - 1] < H[B -1]:
    C[A - 1] += 1
  else:
    C[B - 1] += 1
for j in range(N):
  if C[j] == 0:
    d += 1
print(d)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
h = list(map(int,input().split()))
judge = [True] * n

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

print(judge.count(True))

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
h = list(map(int,input().split()))
judge = [True] * n

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

print(judge.count(True))

Submission status: Wrong Answer

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

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

print(len(set(H)))

Submission status: Wrong Answer

Solution code:
import numpy as np
N,M = map(int, input().split())
H = np.array(list(map(int, input().split())))
box = [[] for _ in range(N)]
for im in range(M):
  a,b = map(int, input().split())
  box[a-1].append(b)
  box[b-1].append(a)
ans = 0
for n in range(N):
  try:
    if H[n]>=np.max(H[np.array(box[n],dtype=int)-1]):
      ans += 1
  except:
    continue
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
 
N, M = map(int, input().split())
H = list(map(int, input().split()))
A = [[] for _ in range(N)]
count = 0
for k in range(1, M+1):
  S = input().split()
  S = [int(x) for x in S]
  if not S[1] in A[S[0]-1]:
    A[S[0]-1].append(S[1])
    A[S[1]-1].append(S[0])
for i in range(N):
  lis = A[i]
  if lis == []:
    continue
  Hlis = []
  for k in lis:
    Hlis.append(H[k-1])
  if max(H[i], max(Hlis)) == H[i]:
    count += 1
print(count)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
 
N, M = map(int, input().split())
H = list(map(int, input().split()))
A = [[] for _ in range(N)]
count = 0
for k in range(1, M+1):
  S = input().split()
  S = [int(x) for x in S]
  if not S[1] in A[S[0]-1]:
    A[S[0]-1].append(S[1])
    A[S[1]-1].append(S[0])
for i in range(N):
  lis = A[i]
  if lis == []:
    continue
  if max(H[i], max(lis)) == H[i]:
    count += 1
print(count)

Submission status: Wrong Answer

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

N, M = map(int, input().split())
H = list(map(int, input().split()))
A = [[] for _ in range(N)]
count = 0
for k in range(1, M+1):
  S = input().split()
  S = [int(x) for x in S]
  if not S[1] in A[S[0]-1]:
    A[S[0]-1].append(S[1])
    A[S[1]-1].append(S[0])
for i in range(N):
  lis = A[i]
  if lis == []:
    continue
  judge = True
  for k in lis:
    if H[i] >= H[k-1]:
#      print(str(i) + ", " + str(k-1))
#      print(str(H[i]) + ">" + str(H[k-1]))
      judge = False
  if judge == True:
    count += 1
print(count)

Submission status: Wrong Answer

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

N, M = map(int, input().split())
H = list(map(int, input().split()))
A = [[] for _ in range(N)]
count = 0
for k in range(1, M+1):
  S = input().split()
  S = [int(x) for x in S]
  if not S[1] in A[S[0]-1]:
    A[S[0]-1].append(S[1])
    A[S[1]-1].append(S[0])
for i in range(N):
  lis = A[i]
  if lis == []:
    continue
  judge = True
  for k in lis:
    if H[i] > H[k-1]:
#      print(str(i) + ", " + str(k-1))
#      print(str(H[i]) + ">" + str(H[k-1]))
      judge = False
  if judge == True:
    count += 1
print(count)

Submission status: Wrong Answer

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

N, M = map(int, input().split())
H = list(map(int, input().split()))
A = [[] for _ in range(N)]
count = 0
for k in range(1, M+1):
  S = input().split()
  S = [int(x) for x in S]
  if not S[1] in A[S[0]-1]:
    A[S[0]-1].append(S[1])
    A[S[1]-1].append(S[0])
for i in range(N):
  lis = A[i]
  if lis == []:
    continue
  judge = True
  for k in lis:
    if H[i] < H[k-1]:
      judge = False
  if judge == True:
    count += 1
print(count)

Submission status: Wrong Answer

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

N, M = map(int, input().split())
H = list(map(int, input().split()))
A = [[] for _ in range(N)]
count = 0
for k in range(1, M+1):
  S = input().split()
  S = [int(x) for x in S]
  if not S[1] in A[S[0]-1]:
    A[S[0]-1].append(S[1])
    A[S[1]-1].append(S[0])
for i in range(N):
  lis = A[i]
  if lis == []:
    continue
  judge = True
  for k in lis:
    if H[i] < k:
      judge = False
  if judge == True:
    count += 1
print(count)

Submission status: Wrong Answer

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

N, M = map(int, input().split())
H = list(map(int, input().split()))
A = [[] for _ in range(N)]
count = 0
for k in range(1, M+1):
  S = input().split()
  S = [int(x) for x in S]
  if not S[1] in A[S[0]-1]:
    A[S[0]-1].append(S[1])
    A[S[1]-1].append(S[0])
print(A)
for i in range(N):
  lis = A[i]
  if lis == []:
    continue
  judge = True
  for k in lis:
    if H[i] < k:
      judge = False
  if judge == True:
    count += 1
print(count)

Submission status: Wrong Answer

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

N, M = map(int, input().split())
H = list(map(int, input().split()))
A = [[] for _ in range(N)]
count = 0
for k in range(1, M+1):
  S = input().split()
  S = [int(x) for x in S]
  A[S[0]-1].append(S[1])
  A[S[1]-1].append(S[0])
for i in range(N):
  lis = A[i]
  if lis == []:
    continue
  judge = True
  for k in lis:
    if H[i] < k:
      judge = False
  if judge == True:
    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())
    #0_index
    A[i] -= 1
    B[i] -= 1

ans = [1] * N

for i in range(M):
    if H[A[i]] < H[B[i]]:
        ans[A[i]] = 0
    else:
        ans[B[i]] = 0

#print("ans", ans)
print(ans.count(1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
import numpy as np
import sys
import os
from operator import mul
from operator import itemgetter

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353    

N,M = LI()
H = LI()
AB = [LI() for _ in range(M)]

p = []
d = {}
for i in range(N):
    # p.append((i,H[i]))
    d[i]=H[i]
# p.sort(key=itemgetter(1),reverse=True)
# print(p)
print(d)

# g = np.zeros(shape=(N,N),dtype='int')
g = [set()] * N
a = [True] * N

for i in range(M):
    f = AB[i][0]-1
    t = AB[i][1]-1
    if d[t]>d[f]:
        a[f]=False
    elif d[f]>d[t]:
        a[t]=False
    else:
        a[f]=False
        a[t]=False
# print(a)
print(sum(a))  
    # print(g[f])
    # g[f] = np.append(g[f],t)
    # g[t] = np.append(g[t],f)
   
    # g[f][t]=1
    # g[t][f]=1

# print(g)
# list.sort(key=itemgetter(0))

# for i in range(N):


# a = np.where(g[0]==1)
# print(a)