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,K = map(int, input().split())
H = list(map(int, input().strip().split()))
A = []
for i in range(0,K):
    array = list(map(int, input().strip().split()))
    A.append(array)
des = []
for i in range(0,K):
    print(H[A[i][0]-1])
    print(H[A[i][1]-1])
    if(H[A[i][0]-1] > H[A[i][1]-1]):
       des.append(H[A[i][1]-1])
    else:
        des.append(H[A[i][0]-1])
ans = sorted(set(des), key=des.index)
print(N-len(ans))

Submission status: Wrong Answer

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

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

##ans = 0
#for j in range(n):
#  flag = False
#  if ab[j] == h[j]:
#    flag = True
#  if flag:
#    ans += 1
print(len(set(ab)))

Submission status: Wrong Answer

Solution code:
n, m = list(map(int, input().split()))
hs =  list(map(int, input().split()))
ans = [1]*n
for i in range(m):
    road = list(map(int, input().split()))
    if hs[road[0]-1] <= hs[road[1]-1]:
        ans[road[0]-1] = 0
    if hs[road[0]-1] >= hs[road[1]-1]:
        ans[road[1]-1] = 0
print(ans.count(0))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().rstrip().split())
h = input().rstrip().split()
l = []
high = [0] * n
count = 0

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

for i in l:
    if h[i[0]-1] < h[i[1]-1]:
        high[i[0]-1] += 1
    elif h[i[0]-1] == h[i[1]-1]:
        high[i[0]-1] += 1
        high[i[1]-1] += 1
    else:
        high[i[1]-1] += 1

for hi in high:
    if hi == 0:
        count += 1
print(count)

Submission status: Wrong Answer

Solution code:
#展望台i：1 ~ Nこの展望台
#Hi: 展望台iの高さ

from copy import deepcopy
from pprint import pprint

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

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

maxlist = [i for i in range(n)]
pairlist = [0] * n

for _ in range(m):
    a,b = map(int,input().split())
    if h[maxlist[a-1]] > h[b-1] and h[maxlist[a-1]] > h[maxlist[b-1]]:
        maxlist[b-1] = a-1
    elif h[maxlist[a-1]] < h[b-1]:
        maxlist[a-1] = b-1
    
    if h[a-1] == h[b-1]:
        pairlist[a-1] = 1
        pairlist[b-1] = 1

counter = 0
for j in range(n):
    if maxlist[j] ==j and pairlist[j] != 1:
        counter += 1

#print(maxlist)
#print(counter)
#print(pairlist)

print(counter)

exit()

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
H = list(map(int, input().split()))
cnt = 0
l = [0]*N
B = [0]*N
AB = list()
for m in range(M):
    P = list(map(int, input().split()))
    AB.append(P)
for m in range(M):
    B[AB[m][0]-1] += 1
    B[AB[m][1]-1] += 1
    if H[AB[m][0]-1] >= H[AB[m][1]-1]:
        l[AB[m][0]-1] += 1
    
    if H[AB[m][0]-1] <= H[AB[m][1]-1]:
        l[AB[m][1]-1] += 1

for b in B:
    if b == 0:
        cnt += 1
for i in l:
    if i != 0:
        cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
#展望台i：1 ~ Nこの展望台
#Hi: 展望台iの高さ

from copy import deepcopy
from pprint import pprint

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

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

maxlist = [i for i in range(n)]
pairlist = [0] * n

for _ in range(m):
    a,b = map(int,input().split())
    if h[maxlist[a-1]] > h[b-1] and h[maxlist[a-1]] > h[maxlist[b-1]]:
        maxlist[b-1] = a-1
    elif h[maxlist[a-1]] < h[b-1]:
        maxlist[a-1] = b-1
    elif h[a-1] == h[b-1]:
        pairlist[a-1] = 1
        pairlist[b-1] = 1

counter = 0
for j in range(n):
    if maxlist[j] ==j:
        counter += 1

print(counter - pairlist.count(1))

exit()

Submission status: Wrong Answer

Solution code:
n, m = list(map(int, input().split()))
hs = list(map(int, input().split()))
ans = [1]*n
for i in range(m):
    road = list(map(int, input().split()))
    if hs[road[0]-1] <= hs[road[1]-1]:
        ans[road[0]-1] = 0
    if hs[road[0]-1] >= hs[road[1]-1]:
        ans[road[1]-1] = 0
print(ans.count(0))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
list_height = list(map(int, input().split()))
list_way = []
list_goodpoint = [1]*n
for i in range(m):
  list_way.append(list(map(int, input().split())))

for way in list_way:
  if way[0] == way[1]:
    list_goodpoint[way[0]-1] = 0
    list_goodpoint[way[1]-1] = 0
  if way[0] > way[1]:
    list_goodpoint[way[1]-1] = 0
  if way[0] < way[1]:
    list_goodpoint[way[0]-1] = 0
print(sum(list_goodpoint))

Submission status: Wrong Answer

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

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

ans = []

for i in range(m):
    if h[a[i][0]-1] < h[a[i][1]-1]:
        ans.append(a[i][0]-1)
    else:
        ans.append(a[i][1]-1)
    
ans = set(ans)
ans = int(len(h)) - int(len(ans))

print(ans)

Submission status: Wrong Answer

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

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

ans = []

for i in range(m):
    if h[a[i][0]-1] < h[a[i][1]-1]:
        ans.append(a[i][0]-1)
    else:
        ans.append(a[i][1]-1)
    
ans = set(ans)
ans = int(len(h)) - int(len(ans))

print(h)
print(a)
print(ans)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
H = list(map(int, input().split()))
cnt = 0
l = [0]*N
B = [0]*N
AB = list()
for m in range(M):
    P = list(map(int, input().split()))
    AB.append(P)
for m in range(M):
    B[AB[m][0]-1] += 1
    B[AB[m][1]-1] += 1
    if H[AB[m][0]-1] > H[AB[m][1]-1]:
        l[AB[m][0]-1] += 1
    
    if H[AB[m][0]-1] < H[AB[m][1]-1]:
        l[AB[m][1]-1] += 1

for b in B:
    if b == 0:
        cnt += 1
for i in l:
    if i != 0:
        cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
H = list(map(int, input().split()))
cnt = 0
l = [0]*N
B = [0]*N
AB = list()
for m in range(M):
    P = list(map(int, input().split()))
    AB.append(P)
for m in range(M):
    B[AB[m][0]-1] += 1
    B[AB[m][1]-1] += 1
    if H[AB[m][0]-1] > H[AB[m][1]-1]:
        l[AB[m][0]-1] += 1
    elif H[AB[m][0]-1] < H[AB[m][1]-1]:
        l[AB[m][1]-1] += 1

for b in B:
    if b == 0:
        cnt += 1
for i in l:
    if i != 0:
        cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
n, m = list(map(int, input().split()))
hs =  list(map(int, input().split()))
ans = [1]*n
for i in range(m):
    road = list(map(int, input().split()))
    if hs[road[0]-1] <= hs[road[1]-1]:
        ans[road[0]-1] = 0
    if hs[road[0]-1] >= hs[road[1]-1]:
        ans[road[1]-1] = 0
print(ans.count(0))

Submission status: Wrong Answer

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

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

ans = []

for i in range(m):
    if h[a[i][0]-1] < h[a[i][1]-1]:
        ans.append(a[i][1]-1)
    else:
        ans.append(a[i][0]-1)
    
ans = set(ans)

print(len(ans))

Submission status: Wrong Answer

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

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

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

ans = 0

for i in range(n):
    ok = True
    for j in to[i]:
        if(h[i] <= h[j]):
            ok = False
    if(ok):
        ans += 1

print(ans)

Submission status: Wrong Answer

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

roads = [list(map(int, input().split())) for i in range(M)]

highest = set([i + 1 for i in range(N)])

for road in roads:
	if Ks[road[1] - 1] > Ks[road[0] - 1]:
		if road[0] in highest:
			highest.remove(road[0])
	else:
		if road[1] in highest:
			highest.remove(road[1])

print(len(highest))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
H = list(map(int, input().split()))
ma = [0]*N

for i in range(M):
    a, b = map(int, input().split())
    ma[a-1] = max(ma[a-1], H[b-1])
    ma[b-1] = max(ma[b-1], H[a-1])
ans = 0
for i in range(1, N):
    if ma[i] < H[i]:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
'''SDESTINY
N個の展望台の一つ一つずつと繋がっている展望台の番号(0-index)を
setに格納する配列を作る。
全体でN個、その中に繋がっている展望台の数だけ、要素がある。
要素はsetで持っていうる。
そのsetの中から要素を一つ一つ取り出す（（C)の部分）。
取り出した高さH[x]と、いま見ている展望台の高さH[i]を比べて、
H[i]<=H[x]なら、条件に合わない（等号は必要か？）
N 箇所の展望台があり展望台 i の標高が Hi、また展望台を結ぶ道が M 本あり、
道 j は展望台 Aj と Bj を結んでいる。展望台から伸びている道
を1つだけ通って行ける展望台のうち最も高い展望台を良い展望台と呼び、
それがいくつあるか求める。
（A)N 箇所の展望台 i に対応するように配列を作り、
各展望台から道が繋がっている展望台をsetで持つ。0-index
配列を順番に見ていき、見ている展望台とsetが持っている
展望台の高さを比較し、最も高ければ答えを1増やす。
'''
N,M = map(int,input().split())
H = list(map(int,input().split()))
AB = [set() for i in range(N)]#（A)
for i in range(M):
    A,B = map(int,input().split())
    AB[A-1].add(B-1)#0-indexへ
    AB[B-1].add(A-1)
#print(AB)
ans = 0
for i in range(N):#iは見ている展望台をチェック
    res = True
    for x in AB[i]:#（C)二重ループ
    #setのi番目にある複数の要素をxとして一つずつ取り出す
#配列を順番に見ていき、見ている展望台iとsetが持っている
#展望台xの高さを比較し、低ければ条件に合わない
        if H[i]<H[x]:#これが（B)のif、等号なしでトライ☆
            #print(H[i],H[x])
            res = False
            break
    if res:#（B)のifでbreakしなければ、最も高いので答を１増やす
        ans += 1
print(ans)

Submission status: Wrong Answer

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

# C - Peaks
import copy

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

obs = copy.copy(h)

for i in range(m):
	a, b = map(int, input().split())
	a -= 1
	b -= 1
	
	height = max(obs[a], obs[b])
	obs[a] = height
	obs[b] = height
	#print(obs)

ans = 0

for i in range(n):
	if obs[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(' ')))
c = [[] for i in range(n)]
for i in range(m):
    a, b = map(int, input().split(' '))
    c[a - 1].append(b - 1)
    c[b - 1].append(a - 1)
r = 0
for i in range(n):
    mh = 1
    for j in c[i]:
        mh = h[j] if mh < h[j] else mh
    r += 1 if h[i] > mh  else 0
print(r)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split(' '))
h = list(map(int, input().split(' ')))
c = [[] for i in range(n)]
for i in range(m):
    a, b = map(int, input().split(' '))
    c[a - 1].append(b - 1)
    c[b - 1].append(a - 1)
r = 0
for i in range(n):
    mh = 1
    for j in c[i]:
        mh = h[j] if mh < h[j] else mh
    r += 1 if h[i] > mh or len([i]) == 0 else 0
print(r)

Submission status: Wrong Answer

Solution code:
N, M = input().split()
view = [int(i) for i in input().split()]
result = set()
remove = set()
for _ in range(int(M)):
  A, B = [int(i) for i in input().split()]
  if view[A-1] > view[B-1]:
    if A not in remove:
      result.add(A)
    try:
      remove.add(B)
      result.remove(B)
    except KeyError:
      pass
  elif view[A-1] < view[B-1]:
    if B not in remove:
      result.add(B)
    try:
      remove.add(A)
      result.remove(A)
    except KeyError:
      pass
  else:
    if A not in remove:
      result.add(A)
    if B not in remove:
      result.add(B)
print(len(result))

Submission status: Wrong Answer

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

observatiories = [0]* (n + 1)

for i in range(m):
	a, b = map(int, input().split())
	height = max(h[a-1], h[b-1])
	observatiories[a] = max(observatiories[a], height)
	observatiories[b] = max(observatiories[b], height)

ans = 0

for i in range(1, n + 1):
	if observatiories[i] == h[i-1]:
		ans += 1

print(ans)

Submission status: Wrong Answer

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

# C - Peaks
n, m = map(int, input().split())
h = list(map(int, input().split()))

observatiories = [0]* (n + 1)

for i in range(m):
	a, b = map(int, input().split())
	height = max(h[a-1], h[b-1])
	observatiories[a] = max(observatiories[a], height)
	observatiories[b] = max(observatiories[b], height)

ans = 0

for i in range(1, n + 1):
	if observatiories[i] == h[i-1]:
		ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split(' '))
h = list(map(int, input().split(' ')))
c = [[] for i in range(n)]
for i in range(m):
    a, b = map(int, input().split(' '))
    c[a - 1].append(b - 1)
    c[b - 1].append(a - 1)
r = 0
for i in range(n):
    mh = 1
    db = [x for x in c[i] if c[i].count(x) > 1]
    for j in c[i]:
        mh = h[j] if mh < h[j] and not j in db else mh
    r += 1 if h[i] > mh or len([i]) == 0 else 0
print(r)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
H = [int(x) for x in input().split()]
ifChecked = [0 for _ in range(N)]
path = [[] for _ in range(N)]
for _ in range(M):
    A, B = map(int, input().split())
    # ここのindexには気をつける
    path[A-1].append(B)
    path[B-1].append(A)

count = 0
for i in range(1, N+1):
    # このifCheckはLowestとして計上されているかどうかのもの
    my_height = H[i-1]
    ifHighest = True
    if path[i-1] == []:
        continue
    for to in path[i-1]:
        if my_height < H[to-1]:
            ifHighest = False
    if ifHighest:
        count += 1

print(count)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
H = [int(x) for x in input().split()]
ifChecked = [0 for _ in range(N)]
path = [[] for _ in range(N)]
for _ in range(M):
    A, B = map(int, input().split())
    # ここのindexには気をつける
    path[A-1].append(B)
    path[B-1].append(A)

count = 0
for i in range(1, N+1):
    if not ifChecked[i-1] == 0:
        continue
    my_height = H[i-1]
    ifHighest = True
    if path[i-1] == []:
        continue
    for to in path[i-1]:
        if my_height < H[to-1]:
            ifHighest = False
    if ifHighest:
        count += 1
        for to in path[i-1]:
            ifChecked[to-1] = 1

print(count)

Submission status: Wrong Answer

Solution code:
import itertools

n, m = map(int, input().split())
height = list(map(int, input().split()))
path = [list(map(int, input().split())) for _ in range(m)]

num = list(set(itertools.chain.from_iterable(path)))

count = 0
for i in range(1, n + 1):
    if i not in num:
        count += 1
    else:
        connect = [p for p in path if p[0] == i or p[1] == i]
        connect = list(set(itertools.chain.from_iterable(connect)))
        connect.remove(i)
        heigher = [c for c in connect if height[c - 1] > height[i - 1]]
        if len(heigher) == 0:
            count += 1

print(count)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split(' '))
h = list(map(int, input().split(' ')))
c = [[] for i in range(n)]
for i in range(m):
    a, b = map(int, input().split(' '))
    c[a - 1].append(b - 1)
    c[b - 1].append(a - 1)
r = 0
for i in range(n):
    gd , db= True , False
    for j in range(len(c[i])):
        if c[i].count(c[i][j]) > 1:
            db = True
            continue
        if h[i] <= h[c[i][j]]:
            gd , db = False, False
            break
   
    r += 1 if gd and not db else 0
print(r)

Submission status: Wrong Answer

Solution code:
N, M = input().split()
view = [int(i) for i in input().split()]
result = set()
remove = set()
for _ in range(int(M)):
  A, B = [int(i) for i in input().split()]
  if view[A-1] > view[B-1]:
    result.add(A)
    try:
      remove.add(B)
      result.remove(B)
    except KeyError:
      pass
  elif view[A-1] < view[B-1]:
    result.add(B)
    try:
      remove.add(A)
      result.remove(A)
    except KeyError:
      pass
  else:
    if A not in remove:
      result.add(A)
    if B not in remove:
      result.add(B)
print(len(result))

Submission status: Wrong Answer

Solution code:
N, M = input().split()
view = [int(i) for i in input().split()]
result = set()
for _ in range(int(M)):
  A, B = [int(i) for i in input().split()]
  if view[A-1] > view[B-1]:
    result.add(A)
    try:
      result.remove(B)
    except KeyError:
      pass
  else:
    result.add(B)
    try:
      result.remove(A)
    except KeyError:
      pass
print(len(result))

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(b-1)
  if H[a-1] < H[b-1]:
    L.append(a-1)
  else:
    L.append(a-1)
    L.append(b-1)
print(N - len(set(L)))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
H = list(map(int, input().split()))
conditions = [[] for _ in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    # 本当は1個ずつ読み込みながら低い方を判定して、記録しておくといい
    # やっぱり安易に読み込みを急ぐとダメだな
    conditions[a - 1].append(b - 1)
    conditions[b - 1].append(a - 1)

bad_count = [1] * N
for i, cond in enumerate(conditions):
    for j in cond:
        if H[i] < H[j]:
            bad_count[i] = 0

print(N - sum(bad_count))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
H = list(map(int, input().split()))
conditions = [[] for _ in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    # 本当は1個ずつ読み込みながら低い方を判定して、記録しておくといい
    # やっぱり安易に読み込みを急ぐとダメだな
    conditions[a - 1].append(b - 1)
    conditions[b - 1].append(a - 1)

bad_count = [1] * N
for i, cond in enumerate(conditions):
    for j in cond:
        if H[i] < H[j]:  # bimyou
            bad_count[i] = 0
            print(f'{i} is bad')

print(N - sum(bad_count))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
H = list(map(int, input().split()))
conditions = [[] for _ in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    # 本当は1個ずつ読み込みながら低い方を判定して、記録しておくといい
    # やっぱり安易に読み込みを急ぐとダメだな
    conditions[a - 1].append(b - 1)
    conditions[b - 1].append(a - 1)

bad_count = [1] * N
for i, cond in enumerate(conditions):
    for j in cond:
        if H[i] <= H[j]:  # bimyou
            bad_count[i] = 0

print(N - sum(bad_count))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
H = list(map(int, input().split()))
AB = []
cnt = 0
candidate = []
appear = []
div = 0
for i in range(m):
    a, b = map(int, input().split())
    ab = [a, b]
 
    if ab in AB:
        pass
    else:
        AB.append(ab)
        if H[a-1] > H[b-1]:
            candidate.append(H[a-1])
        elif H[a-1] < H[b-1]:
            candidate.append(H[b-1])
        else:
            div += 1
 
    appear.append(H[a-1])
    appear.append(H[b-1])
 
    """if H[a-1] > H[b-1]:
        candidate.append(H[a-1])
    elif H[a-1] < H[b-1]:
        candidate.append(H[b-1])
    else:
        div += 1"""
 
    """if ab in AB:
        pass
    else:
        AB.append(ab)"""
 
"""for j, k in (AB):
    appear.append(H[j-1])
    appear.append(H[k-1])
    if H[j-1] > H[k-1]:
        candidate.append(H[j-1])
    elif H[j-1] < H[k-1]:
        candidate.append(H[k-1])
    else:
        div += 1"""
 
#print(AB)
#print(candidate)
 
set_candidate = set(candidate)
set_appear = set(appear)
 
#print(set_candidate)
#print(set_appear)
 
ans = len(set_candidate) + (len(H) - len(set_appear)) - div
print(ans)
#print(div)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
H = list(map(int, input().split()))
conditions = [[] for _ in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    # 本当は1個ずつ読み込みながら低い方を判定して、記録しておくといい
    # やっぱり安易に読み込みを急ぐとダメだな
    conditions[a - 1].append(b - 1)
    conditions[b - 1].append(a - 1)

bad_count = [1] * N
for i, cond in enumerate(conditions):
    for j in cond:
        if H[i] <= H[j]:  # bimyou
            bad_count[i] = 0
            print(f'{i} is bad')

print(N - sum(bad_count))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
H = list(map(int, input().split()))
AB = []
cnt = 0
candidate = []
appear = []
div = 0
for i in range(m):
    a, b = map(int, input().split())
    ab = [a, b]
 
    if ab in AB:
        pass
    else:
        AB.append(ab)
        if H[a-1] > H[b-1]:
            candidate.append(H[a-1])
        elif H[a-1] < H[b-1]:
            candidate.append(H[b-1])
        else:
            div += 1
 
    appear.append(H[a-1])
    appear.append(H[b-1])
 
    """if H[a-1] > H[b-1]:
        candidate.append(H[a-1])
    elif H[a-1] < H[b-1]:
        candidate.append(H[b-1])
    else:
        div += 1"""
 
    """if ab in AB:
        pass
    else:
        AB.append(ab)"""
 
"""for j, k in (AB):
    appear.append(H[j-1])
    appear.append(H[k-1])
    if H[j-1] > H[k-1]:
        candidate.append(H[j-1])
    elif H[j-1] < H[k-1]:
        candidate.append(H[k-1])
    else:
        div += 1"""
 
#print(AB)
#print(candidate)
 
set_candidate = set(candidate)
set_appear = set(appear)
 
#print(set_candidate)
#print(set_appear)

Submission status: Wrong Answer

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

def compare_height(adj, h, i):
    height = h[i - 1]
    if not adj[i]:
        return False
    for j in adj[i]:
        if h[j - 1] > height:
            return False
    return True
#adj list
for i in range(m):
    a, b = map(int, input().split())
    adj[a].append(b)
    adj[b].append(a)
#compute number of peaks
for i in range(len(adj)):
    if i == 0:
        continue
    if compare_height(adj, h, i):
        count +=1
print(count)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
N,M = map(int, input().split())
Hs = list(map(int, input().split(" ")))

edges = [defaultdict(int) for _ in range(N+1)]
for i in range(M):
    A,B = map(int, input().split(" "))
    edges[A][B] += 1
    edges[B][A] += 1

ans = 0
for i,e in enumerate(edges):
    if e == {}:
        continue
    good = True
    for neightboor in e.keys():
        if Hs[neightboor - 1] > Hs[i -1]:
            good = False
    if good == True:
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
N,M = map(int, input().split())
Hs = list(map(int, input().split(" ")))

edges = [defaultdict(int) for _ in range(N+1)]
for i in range(M):
    A,B = map(int, input().split(" "))
    edges[A][B] += 1
    edges[B][A] += 1

ans = 0
for i,e in enumerate(edges):
    if e == {}:
        continue
    good = True
    for neightboor in e.keys():
        if Hs[neightboor - 1] > Hs[i -1]:
            good = False
    if good == True:
        print(i, e)
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
N,M = map(int, input().split())
Hs = list(map(int, input().split(" ")))

edges = [defaultdict(int) for _ in range(N+1)]
for i in range(M):
    A,B = map(int, input().split(" "))
    edges[A][B] += 1
    edges[B][A] += 1

ans = 0
for i,e in enumerate(edges):
    if e == {}:
        continue
    good = True
    for neightboor in e.keys():
        if e[neightboor] > 1 or Hs[neightboor - 1] > Hs[i -1]:
            good = False
    if good == True:
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
N,M = map(int, input().split())
Hs = list(map(int, input().split(" ")))

edges = [defaultdict(int) for _ in range(N+1)]
for i in range(M):
    A,B = map(int, input().split(" "))
    edges[A][B] += 1
    edges[B][A] += 1

ans = 0
print(edges)
for i,e in enumerate(edges):
    if e == {}:
        continue
    good = True
    for neightboor in e.keys():
        if e[neightboor] > 1 or Hs[neightboor - 1] > Hs[i -1]:
            good = False
    if good == True:
        ans += 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())
  g[a-1].append(b-1); g[b-1].append(a-1)

ans = 0
for i in range(N):
  neighbors = g[i]
  h = H[i]
  res = True
  for node in neighbors:
    res *= h > H[node]
  if(res):
    print(i+1)
  ans += res

print(ans)

Submission status: Wrong Answer

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

H=list(map(int,input().split()))
l=[]
for j in range(m):
    a,b=map(int,input().split())
    
        
    if H[a-1]>H[b-1]:
        l+=[a]
    else:
        l+=[b]
        
print(len(set(l)))

Submission status: Wrong Answer

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

a = [0]*N
b = []

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

    if A not in b:
        b.append(A)
    if B not in b:
        b.append(B)

    if H[A-1] > H[B-1]:
        a[A-1] = 1
        a[B-1] = 0
    elif H[A-1] == H[B-1]:
        a[A - 1] = 0
        a[B - 1] = 0
    else:
        a[A - 1] = 0
        a[B - 1] = 1

an = 0

for i in range(1,N+1):
    if i not in b:
        an += 1


print(a.count(1) + an)

Submission status: Wrong Answer

Solution code:
# C - Peaks
def main():
    N, M, *HAB = map(int, open(0).read().split())
    H, AB = HAB[:N], HAB[N:]

    graph = [[] for _ in range(N + 1)]
    for a, b in zip(*[iter(AB)] * 2):
        graph[a].append(b)
        graph[b].append(a)

    cnt = 0
    determined = [False] * (N + 1)
    for _, u in sorted(((h, i) for i, h in enumerate(H, 1)), reverse=True):
        if determined[u]:
            continue
        cnt += 1
        determined[u] = True
        for v in graph[u]:
            determined[v] = True

    print(cnt)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import copy

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

ll=[0]*n

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

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

Submission status: Wrong Answer

Solution code:
# C - Peaks
def main():
    N, M, *HAB = map(int, open(0).read().split())
    H, AB = HAB[:N], HAB[N:]

    graph = [[] for _ in range(N + 1)]
    for a, b in zip(*[iter(AB)] * 2):
        graph[a].append(b)
        graph[b].append(a)

    cnt = 0
    determined = [False] * (N + 1)
    for _, u in sorted((h, i) for i, h in enumerate(H, 1)):
        if determined[u]:
            continue
        cnt += 1
        determined[u] = True
        for v in graph[u]:
            determined[v] = True

    print(cnt)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
## import

## function definition 

## main process
if __name__ == '__main__':
    
    ## input
    N, M = map(int,input().split())
    HEIGHT_LIST = list(map(int,input().split())) 
    ROAD_LIST = []
    for j in range(M): 
        ROAD_LIST.append(
            tuple(map(int,input().split()))
        )
    
    ## business logic
    ans = [1] * N
    for j in list(range(M)):
        point_a = ROAD_LIST[j][0]
        point_b = ROAD_LIST[j][1]

        point_a =- 1
        point_b =- 1

        height_a = HEIGHT_LIST[point_a]
        height_b = HEIGHT_LIST[point_b]

        if height_a < height_b:
            ans[point_a] = 0
        elif height_a > height_b:
            ans[point_b] = 0
        else:
            ans[point_a] = 0
            ans[point_b] = 0

    ## output
    print(sum(ans))

Submission status: Wrong Answer

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

d = dict()
for i in range(1,n+1):
    d[i] = h[i-1]
    

l_1 = []
l_2 = []
for j in range(1,m+1):
    x, y = map(int,input().split())
    if d[x] > d[y]:
        l_1.append(x)
        l_2.append(x)
        l_2.append(y)
        continue
    elif d[x]==d[y]:
        l_2.append(x)
        l_2.append(y)
        continue
    else:
        l_1.append(y)
        l_2.append(x)
        l_2.append(y)
        continue
        
l_2.extend(l_1)
l_1 = set(l_1)
l_2 = set(l_2)

print(len(l_1) + n - len(l_2))

Submission status: Wrong Answer

Solution code:
def run():
  N, M = map(int, input().split())
  H = [0] * N
  G = [1] * N
  counter = 0
  H = list(map(int, input().split()))
  for _ in range(M):
    a, b = map(int, input().split())
    if H[a-1]<H[b-1]:
      G[a-1] = -1
      G[b-1] = 1
    elif H[a-1]>H[b-1]:
      G[a-1] = 1
      G[b-1] = -1
    else:
      G[a-1] = G[b-1] = -1
  for i in range(N):
    if G[i]==1:
      counter += 1
    else:
      pass
  print(counter)
  
if __name__ == "__main__":
  run()

Submission status: Wrong Answer

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

	x = tenbo[i]
	x1 = x[0]
	x2 = x[1]
	#print(x1)
	y1 = h[x1-1]
	y2 = h[x2-1]
	a = [y1,y2]
	#print(x[1])
	tree[x[0]-1].extend(a)
	tree[x[1]-1].extend(a)
c = 0
for i in range(n):
	if max(tree[i]) <=h[i]:
		if len(tree[i]) > 1:
		#print(max(tree[i]))
			c += 1
print(c)

Submission status: Wrong Answer

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

d = dict()
for i in range(1,n+1):
    d[i] = h[i-1]
    

l_1 = []
l_2 = []
for j in range(1,m+1):
    x, y = map(int,input().split())
    if d[x] > d[y]:
        l_1.append(x)
        l_2.append(x)
        l_2.append(y)
        continue
    elif d[x]==d[y]:
        l_2.append(x)
        l_2.append(y)
        continue
    else:
        l_1.append(y)
        l_2.append(x)
        l_2.append(y)
        continue
        

l_1 = set(l_1)
l_2 = set(l_2)

print(len(l_1) + n - len(l_2))

Submission status: Wrong Answer

Solution code:
from dataclasses import dataclass 
from collections import  defaultdict
from pprint import  pprint

@dataclass
class mount:
    id: int
    height: int

if __name__ == "__main__":
    n,m = list( map( int, input().split(' ')) ) 
    ar = list(map(int, input().split(" ")))
    d =  defaultdict(lambda : [])
    for i in range(m):
        f,to = list(map(int, input().split(' ')))
        d[f].append(ar[to-1])
        d[to].append(ar[f-1])
    count = 0
    for i in d:
        if all([ ar[i-1] >= x for x in d[i]]):
            count +=1 
    print(count )