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:
a, b = map(int, input().split())
arr = list(map(int, input().split()))

ans_arr = []
for _ in range(a):
    ans_arr.append(0)


input_arr = []
for _ in range(b):
    add_arr = list(map(int, input().split()))
    input_arr.append(add_arr)

for i in range(b):
    if arr[input_arr[i][0]-1] <= arr[input_arr[i][1]-1]:
        ans_arr[input_arr[i][0] - 1] = 0
        ans_arr[input_arr[i][1] - 1] = 1
    else:
        ans_arr[input_arr[i][0] - 1] = 1
        ans_arr[input_arr[i][1] - 1] = 0

print(sum(ans_arr))

Submission status: Wrong Answer

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

max_height = [0]*N
for i in range(M):
    a,b = map(int,input().split())
    max_height[a-1]=max(max_height[a-1],H[b-1])
    max_height[b-1]=max(max_height[b-1],H[a-1])


print((sum(H[i] >= max_height[i] for i in range(N))))

Submission status: Wrong Answer

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

x=[0]*n
for i in range(k):
    a,b = map(int, input().split())
    if h[a-1]>=h[b-1]:
      x[a-1]+=1
    if h[b-1]>=h[a-1]:
      x[b-1]+=1
print(x.count(0))

Submission status: Wrong Answer

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

x=[0]*n
for i in range(k):
    a,b = map(int, input().split())
    if h[a-1]>h[b-1]:
      x[a-1]+=1
    elif h[a-1]<h[b-1]:
      x[b-1]+=1
print(x.count(0))

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
    else:
        ans[b] = 0

print(sum(ans))

Submission status: Wrong Answer

Solution code:
import sys
import itertools

def peeks(f):
    readline = f.readline
    n, m = map(int, readline().split())
    h = tuple(itertools.chain(
        [0],
        map(int, readline().split())))
    observatories = tuple(tuple(map(int, line.split())) for line in f)
    # print(n, m)
    # print(f'{h=}')
    # print(f'{observatories=}')

    L = [0] * (n + 1)
    for a, b in observatories:
        L[a] = max(L[a], h[a])
        L[b] = max(L[a], h[a])

    # print(f'{L=}')
    ans = sum(1 for index, elevation in enumerate(L[1:], 1) if h[index] > elevation)

    return ans


def main():
    ans = peeks(sys.stdin.buffer)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np

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

map_ = {str(i):[] for i in range(n)}

for _ in range(m):
  a, b = map(int, input().split())
  map_[str(a-1)].append(b-1)
  map_[str(b-1)].append(a-1)
  
cnt=0
for i in range(n):
  tmp = [h_list[i]] + [h_list[j] for j in map_[str(i)]]
  hiest = max(tmp)
  if tmp.count(hiest)!=1:
    break
  else:
    if tmp.index(max(tmp))==0:
      cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

map_ = {str(i):[] for i in range(n)}

for _ in range(m):
  a, b = map(int, input().split())
  map_[str(a-1)].append(b-1)
  map_[str(b-1)].append(a-1)
  
cnt=0
for i in range(n):
  tmp = [h_list[i]] + [h_list[j] for j in map_[str(i)]]
  if tmp.index(max(tmp))==0:
    cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

mtx = [[0]*n for _ in range(n)]

for i in range(n):
  mtx[i][i] = 1

for _ in range(m):
  a, b = map(int, input().split())
  mtx[a-1][b-1] = 1
  mtx[b-1][a-1] = 1
  
cnt=0
for i in range(n):
  tmp = np.array(mtx[i])*np.array(h_list)
  tmp = tmp.tolist()
  if tmp.index(max(tmp))==i:
    cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
import collections

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

memo = [-1] *N
for _ in range(M):
    A, B = map(int, input().split())
    A -= 1
    B -= 1

    memo[A] = max(memo[A], memo[B], H[A], H[B])
    memo[B] = max(memo[A], memo[B], H[A], H[B])

c = collections.Counter(memo)

answer = 0
for v in c.values():
    if v >= 2:
        answer += v -1

print(answer)

Submission status: Wrong Answer

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

for i in range(m):
 a,b=map(int,input().split())
 ng_h.append(a)
 gd_h.append(b)
 gd_h.extend(h)

gd_h2=list(set(gd_h)-set(ng_h))
print(len(gd_h2))

Submission status: Wrong Answer

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

A_B = [""] * M

for c in range(M):
    A_B[c] = list(map(int, input().split()))

hd = {}

for co in range(N):
    hd[co + 1] = H[co]

print(hd)
print("a")

Submission status: Wrong Answer

Solution code:
n, m=map(int, input().split())
h=list(map(int,input().split()))
l = [[] for _ in range(n)]
#print(l)
#print(h)
for i in range(m):
  a, b=map(int, input().split())
  l[a-1].append(b)
  l[b-1].append(a)
ans=0
print(l)
for x in range(n):
  for y in range(len(l[x])):
    if h[x]<=h[l[x][y]-1]:
      break
  else:
    print(x)
    ans+=1
    continue

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a = [0] * 10**5
b = [a] * 10**5

Submission status: Wrong Answer

Solution code:
def main():
    n, m = map(int,input().split())
    hlis = list(map(int, input().split()))
    hdic = {}
    rdic = {}
    for i in range(1, len(hlis)+1):
        hdic[i] = hlis[i-1]
    for j in range(m):
        a, b = map(int, input().split())
        if a in rdic:
            if rdic[a] < hdic[b]:
                rdic[a] = hdic[b]
        else:
            rdic[a] = hdic[b]
        if b in rdic:
            if rdic[b] < hdic[a]:
                rdic[b] = hdic[a]
        else:
            rdic[b] = hdic[a]
    ans = 0
    for key in rdic:
        if rdic[key] >= hdic[key]:
            ans += 1
    print(ans)



    
    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

cnt = 0
for j in x:
    if j == 1:
        cnt += 1
print(cnt)

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)]
abf = [e for row in ab for e in row]
x = [0] * n
for i in range(1, n+1):
    if i not in abf:
        x[i-1] = 1

for a, b in ab:
    if h[a-1] > h[b-1]:
        x[a-1] = 1
        x[b-1] = 0
    elif h[a-1] < h[b-1]:
        x[a-1] = 0
        x[b-1] = 1
    else:
        x[a-1] = 0
        x[b-1] = 0
cnt = 0
for k in x:
    if k == 1:
        cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
import math
import sys

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

lis = [0] * N  


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

    hightA = H[A-1]
    hightB = H[B-1]

    if hightA < hightB:
        if lis[B-1] == 0:
            lis[B-1] = 1
            lis[A-1] = -1
        
        elif lis[B-1] == 1 or lis[B-1] == -1:
            lis[A-1] = -1
    
    if hightB < hightA:
        if lis[A-1] == 0:
            lis[A-1] = 1
            lis[B-1] = -1
        
        elif lis[A-1] == 1 or lis[A-1] == -1:
            lis[B-1] = -1

    if hightB == hightA:
        lis[A-1] = -1
        lis[B-1] = -1

print(lis)

Submission status: Wrong Answer

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

lis = [0] * N  


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

    hightA = H[A-1]
    hightB = H[B-1]

    if hightA > hightB:
        if lis[A-1] == 1:
            pass

        elif lis[A-1] == 0 and lis[A-1] != -1:
            lis[A-1] = 1
            lis[B-1] = -1
        
        elif lis[A-1] == -1:
            pass
    
    if hightA < hightB:
        if lis[B-1] == 1:
            pass

        elif lis[B-1] == 0 and lis[B-1] != -1:
            lis[B-1] = 1
            lis[A-1] = -1
        else:
            lis[B-1] = -1

    if hightA == hightB:
        lis[A-1] = -1
        lis[B-1] = -1


ans = 0  
for i in lis:
    if i == 0 or i == 1:
        ans = ans + 1

print(ans)

Submission status: Wrong Answer

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

N,M = map(int, input().split())
H = [0] + list(map(int, input().split()))
isGood = [0] + [1]*N
highest = [0]*(N+1)

for _ in range(M):
    a,b = map(int, input().split())
    Ha, Hb = H[a], H[b]
    
    if Ha != Hb:
        if Ha > Hb:
            hidx, lidx = a, b
            high, low = Ha, Hb
        elif Ha < Hb:
            hidx, lidx = b, a
            high, low = Hb, Ha
        
        isGood[lidx] = 0
        H[lidx] = high
    else:
        isGood[a], isGood[b] = 0,0

print(sum(isGood))

Submission status: Wrong Answer

Solution code:
import heapq

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

ten = [[] for _ in range(n+1)]
for i in range(m):
    a1,a2 = map(int,input().split())
    ten[a1].append(a2)
    ten[a2].append(a1)

cnt = 0
for i in range(1,n+1):
    rel = ten[i]
    rel.append(i)
    rel = list(map(lambda x: (-h_list[x-1], x), set(rel)))
    heapq.heapify(rel)
    max_ten = heapq.heappop(rel)
    max_height = -max_ten[0]

    if len(rel) > 1:
        next_ten = heapq.heappop(rel)
        next_height = -next_ten[0]
        if max_height == next_height:
            continue

    if max_ten[1] == i:
        cnt += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
import heapq

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

ten = [[] for _ in range(n)]
for i in range(m):
    a1,a2 = map(int,input().split())
    a1,a2 = a1-1, a2-1
    ten[a1].append(a2)
    ten[a2].append(a1)

cnt = 0
for i,rel in enumerate(ten):
    rel.append(i)
    rel = list(map(lambda x: (-h_list[x], x), rel))
    heapq.heapify(rel)
    max_ten = heapq.heappop(rel)
    if max_ten[1] == i:
        cnt += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
H = list(map(int, input().split()))
road = [list(map(int, input().split())) for i in range(M)]
DP = [0 for i in range(N+1)]
DP[0] = -1
kouho = []

for i in range(M):
  Ai = road[i][0]
  Bi = road[i][1]
  if H[Ai - 1] > H[Bi - 1]:
    if DP[Ai] != -1:
      DP[Ai] = 1
    DP[Bi] = -1
  elif H[Ai - 1] == H[Bi - 1]:
    if DP[Ai] != -1 and DP[Bi] != -1:
      DP[Ai] = 1
      DP[Bi] = 1
    else:
      DP[Ai] = -1
      DP[Bi] = -1
  else:
    if DP[Bi] != -1:
      DP[Bi] = 1
    DP[Ai] = -1 

ans = 0
for i in DP:
  if i != -1:
    ans += 1

print(ans)
#print(DP)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
H = list(map(int, input().split()))
road = [list(map(int, input().split())) for i in range(M)]
DP = [0 for i in range(N+1)]
DP[0] = -1
kouho = []

for i in range(M):
  Ai = road[i][0]
  Bi = road[i][1]
  if H[Ai - 1] > H[Bi - 1]:
    if DP[Ai] != -1:
      DP[Ai] = 1
    DP[Bi] = -1
  elif H[Ai - 1] == H[Bi - 1]:
    if DP[Ai] != -1 and DP[Bi] != -1:
      DP[Ai] = 1
      DP[Bi] = 1
    else:
      DP[Ai] = -1
      DP[Bi] = -1
  else:
    if DP[Bi] != -1:
      DP[Bi] = 1
    DP[Ai] = -1 

ans = 0
for i in DP:
  if i != -1:
    ans += 1

print(ans)
print(DP)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
H=list(map(int,input().split()))
a=[]
b=[]
result=[]
count=0
for h in range(N):
    result.append(True)
for i in range(M):
    A,B=map(int,input().split())
    a.append(A)
    b.append(B)
for j in range(M):
    if H[a[j]-1]<H[b[j]-1]:
        result[a[j]-1]=False
for k in range(M):
    if H[a[k]-1]>H[b[k]-1]:
        result[b[j]-1]=False
for x in range(N):
    if x+1 not in a and x+1 not in b:
        result[x]=False
for l in result:
    if l==True:
        count+=1
print(count)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split(' '))
HList = []
ansList = []
for H in input().split():
    HList.append(H)
    ansList.append('1')

for i in range(M):
    A, B = map(int, input().split())
    if HList[A-1] > HList[B-1]:
        ansList[B-1] = '0'

    elif HList[A-1] < HList[B-1]:
        ansList[A-1] = '0'

    elif HList[A-1] == HList[B-1]:
        ansList[A-1] = '0'
        ansList[B-1] = '0'
print(ansList.count('1'))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split(' '))
HList = [0]*N
ansList=[1]*N
Hcount=0
for H in input().split():
    HList[Hcount]=H
    Hcount=Hcount+1

for i in range(M):
    A, B = map(int, input().split())
    if HList[A-1] > HList[B-1]:
        ansList[B-1] = 0

    elif HList[A-1] < HList[B-1]:
        ansList[A-1] = 0

    elif HList[A-1] == HList[B-1]:
        ansList[A-1] = 0
        ansList[B-1] = 0
print(ansList.count(1))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split(' '))
HList = []
ansList=[]
for H in input().split():
    HList.append(H)
    ansList.append(1)

for i in range(M):
    A, B = map(int, input().split())
    if HList[A-1] > HList[B-1]:
        ansList[B-1] = 0

    elif HList[A-1] < HList[B-1]:
        ansList[A-1] = 0

    elif HList[A-1] == HList[B-1]:
        ansList[A-1] = 0
        ansList[B-1] = 0

count=0

for i in range(N):
    if ansList[i]==1:
        count=count+1
print(count)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
HList = []
ansList=[]
for H in input().split():
    HList.append(H)
    ansList.append(1)

for i in range(M):
    A, B = map(int, input().split())
    if HList[A-1] > HList[B-1]:
        ansList[B-1] = 0
    elif HList[A-1] < HList[B-1]:
        ansList[A-1] = 0
    elif HList[A-1] == HList[B-1]:
        ansList[A-1] = 0
        ansList[B-1] = 0

print(ansList.count(1))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
HList = []
ansList=[]
for H in input().split():
    HList.append(H)
    ansList.append(1)

print(ansList)

for i in range(M):
    A, B = map(int, input().split())
    if HList[A-1] > HList[B-1]:
        ansList[B-1] = 0
    elif HList[A-1] < HList[B-1]:
        ansList[A-1] = 0
    elif HList[A-1] == HList[B-1]:
        ansList[A-1] = 0
        ansList[B-1] = 0

print(ansList.count(1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

s = set(range(1, N+1))

def check_good(A,B):
    if H[A-1] >= H[B-1]:
        return B
        
    else:
        return A

[s.difference_update([check_good(*map(int, input().split()))]) for x in range(M)]

print(len(s))

Submission status: Wrong Answer

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

s = set()

def check_good(A,B):
    if H[A-1] < H[B-1]:
        return B
        
    else:
        return A

[s.add(check_good(*map(int, input().split()))) for x in range(M)]

print(len(s))

Submission status: Wrong Answer

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

s = set()

[s.add(max(map(int, input().split()))) for x in range(M)]

print(len(s))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
h_list = list(map(int, input().split()))
good_obs = [1] * N

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

Submission status: Wrong Answer

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

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

    if h[a-1] < h[b-1]:
        result[a-1]=0
    elif h[a-1] > h[b-1]:
        result[b-1]=0

print(sum(result))

Submission status: Wrong Answer

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

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

    if h[a-1] < h[b-1]:
        bad_list.append(a)
    elif h[a-1] > h[b-1]:
        bad_list.append(b)

x = list(set(bad_list))
print(n - len(x))

Submission status: Wrong Answer

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

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

    if h[a-1] < h[b-1]:
        bad_list.append(a)
    else:
        bad_list.append(b)

x = list(set(bad_list))
print(n - len(x))

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):
    ab = list(map(int, input().split()))
    a.append(ab[0])
    b.append(ab[1])

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

x = list(set(bad_list))
print(n - len(x))

Submission status: Wrong Answer

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

h=list(map(int,input().split()))
roads=[]
ans=[False]*n
reached=[False]*n
lost =[False]*n
for i in range(m):
  a,b=map(int,input().split())
  if h[a-1]>h[b-1] and not lost[a-1]:
    ans[a-1]=True
    ans[b-1]=False
    lost[b-1]=True
  elif h[b-1]>h[a-1] and not lost[b-1]:
    ans[b-1]=True
    ans[a-1]=False
    lost[a-1]=True
    
  reached[a-1]=True
  reached[b-1]=True
    

print(ans.count(True)+reached.count(False))

Submission status: Wrong Answer

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

h=list(map(int,input().split()))
roads=[]
ans=[False]*n
reached=[False]*n
for i in range(m):
  a,b=map(int,input().split())
  if h[a-1]>h[b-1]:
    ans[a-1]=True
    ans[b-1]=False
  elif h[b-1]>h[a-1]:
    ans[b-1]=True
    ans[a-1]=False
  reached[a-1]=True
  reached[b-1]=True
    

print(ans.count(True)+reached.count(False))

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):
    ab = list(map(int, input().split()))
    a.append(ab[0])
    b.append(ab[1])

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

print(bad_list)
print(n - len(set(bad_list)))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
lst = [int(x) for x in input().split()]
m = {}
for _ in range(M):
    A, B = map(int, input().split())
    a = m.get(A, [])
    a.append(B)
    m[A] = a
    b = m.get(B, [])
    b.append(A)
    m[B] = b

ret = 0
for i in range(N):
    if m.get(i + 1, 0) == 0:
        ret += 1
    else:
        n = lst[i]
        v = m.get(i + 1)
        f = True
        for i in v:
            if n > i:
                f = False
                break
        if f:
            ret += 1
print(ret)

Submission status: Wrong Answer

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

elevation = {}
for _ in range(len(h)):
    elevation[_+1] = h[_]

obs = list([] for _ in range(len(h)))
for i in range(m):
    obsA, obsB = map(int, input().split())
    if elevation[obsA] == elevation[obsB]:  # elevation[obsA]のvalueをリストにしてTrue追加
        obs[obsA-1].append(0)  # 1==True, 0==False
        obs[obsB-1].append(0)
    elif elevation[obsA] > elevation[obsB]:
        obs[obsA-1].append(1)
        obs[obsB-1].append(0)
    elif elevation[obsA] < elevation[obsB]:
        obs[obsA-1].append(0)
        obs[obsB-1].append(1)

count = 0
for o in obs:  # obsの各リストでTrueの展望台の数をカウント
    if all(o):  # all()は空のリストでもTrueを返す
        count += 1

print(count)
print(elevation)
print(obs)

Submission status: Wrong Answer

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

elevation = {}
for _ in range(len(h)):
    elevation[_+1] = h[_]

obs = list([] for _ in range(len(h)))
for i in range(m):
    obsA, obsB = map(int, input().split())
    if elevation[obsA] == elevation[obsB]:  # elevation[obsA]のvalueをリストにしてTrue追加
        obs[obsA-1].append(1)  # 1==True, 0==False
        obs[obsB-1].append(1)
    elif elevation[obsA] > elevation[obsB]:
        obs[obsA-1].append(1)
        obs[obsB-1].append(0)
    elif elevation[obsA] < elevation[obsB]:
        obs[obsA-1].append(0)
        obs[obsB-1].append(1)

count = 0
for o in obs:  # obsの各リストでTrueの展望台の数をカウント
    if all(o):  # all()は空のリストでもTrueを返す
        count += 1

print(count)

Submission status: Wrong Answer

Solution code:
N, way = map(int, input().split())
high = list(map(int, input().split()))
ans = [1]*N

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

Submission status: Wrong Answer

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

elevation = {}
for _ in range(len(h)):
    elevation[_+1] = h[_]

obs = list([] for _ in range(len(h)))
for i in range(m):
    obsA, obsB = map(int, input().split())
    if elevation[obsA] == elevation[obsB]:  # elevation[obsA]のvalueをリストにしてTrue追加
        obs[obsA-1].append(1)  # 1==True, 0==False
        obs[obsB-1].append(1)
    elif elevation[obsA] > elevation[obsB]:
        obs[obsA-1].append(1)
        obs[obsB-1].append(0)
    elif elevation[obsA] < elevation[obsB]:
        obs[obsA-1].append(0)
        obs[obsB-1].append(1)

count = 0
for o in obs:  # obsの各リストでTrueの展望台の数をカウント
    if all(o):  # all()は空のリストでもTrueを返す
        count += 1

print(count)
print(elevation)
print(obs)

Submission status: Wrong Answer

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

elevation = {}
for _ in range(len(h)):
    elevation[_+1] = h[_]

obs = list([] for _ in range(len(h)))
for i in range(m):
    obsA, obsB = map(int, input().split())
    if elevation[obsA] == elevation[obsB]:  # elevation[obsA]のvalueをリストにしてTrue追加
        obs[obsA-1].append(1)  # 1==True, 0==False
        obs[obsB-1].append(0)
    elif elevation[obsA] > elevation[obsB]:
        obs[obsA-1].append(1)
        obs[obsB-1].append(0)
    elif elevation[obsA] < elevation[obsB]:
        obs[obsA-1].append(0)
        obs[obsB-1].append(1)

count = 0
for o in obs:  # obsの各リストでTrueの展望台の数をカウント
    if all(o):  # all()は空のリストでもTrueを返す
        count += 1

print(count)

Submission status: Wrong Answer

Solution code:
def peak():
    condition = input()
    condition_list = condition.split()
    N = int(condition_list[0])
    M = int(condition_list[1])
    
    height_str = input()
    height_list_str = height_str.split()
    height_list = [0]
    for i in height_list_str:
        height_list.append(int(i))
    
    road_list = []
    for i in range(0, M):
        road_str = input()
        road_set_str = road_str.split()
        road_set = []
        for i in road_set_str:
            road_set.append(int(i))
        road_list.append(road_set)
    
    #road_list = []
    #for i in road_list_str:
        #road_list.append(int(i))
    
    good_point = set()
    for i in range(1, N+1):
        good_point.add(i)
    
    for road_set in road_list:
        i = road_set[0]
        j = road_set[1]
        if height_list[i] < height_list[j]:
            good_point.discard(i)
        elif height_list[i] > height_list[j]:
            good_point.discard(j)
    
    print(len(good_point))
    return

peak()

Submission status: Wrong Answer

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

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
h = list(map(int, input().split()))
delete_list =[]
pairs = []
for i in range(m):
    a, b = map(int, input().split())
    if h[a-1] > h[b-1]:
        delete_list.append(b)
    if h[a-1] == h[b-1]:
        delete_list.append(a)
        delete_list.append(b)
    else:
        delete_list.append(a)

delete_list = set(delete_list)
print(n - len(delete_list))

Submission status: Wrong Answer

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

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

print(good.count(0))

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
H=list(map(int,input().split()))
AB=[set() for i in range(N)]
for i in range(M):
  A,B=map(int,input().split())
  A-=1
  B-=1
  AB[A].add(B)
  AB[B].add(A)
ans=0
for i in range(N):
  #res=True
  for x in AB[i]:
    if H[i]<=H[x]:      
      res=False
      break
  #if res:
  ans+=1
ans=ans//2
print(ans)

Submission status: Wrong Answer

Solution code:
N, M = map(int,input().split())
H = [int(i) for i in input().split()]
P = [[int(i) for i in input().split()] for m in range(M)]
ans=0
for i in range(N):
  good = True
  for j in range(M):
    if(P[j][0]==i and H[i]<=H[P[j][1]-1]):
      good = False
  if(good==True):
    ans = ans+1
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
n, m = map(int, input().split())
h = [0]+list(map(int, input().split()))
ans = [0]+[1]*n
for i in range(m):
    a, b = map(int, input().split())
    if h[a]>=h[b]:
        ans[b] = 0
    elif h[b]>=h[a]:
        ans[a] = 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())
    a,b=a-1,b-1
    if h[a]>=h[b]:
        ans[b] = 0
    elif h[b]>=h[a]:
        ans[a] = 0
print(sum(ans))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
n, m = map(int, input().split())
h = list(map(int, input().split()))
g = [[] for _ in [0]*n]
for i in range(m):
    a, b = map(int, input().split())
    a-=1;b-=1
    g[a] += [b]
    g[b] += [a]
count = 0
x = -1
for j in g:
    if j == []:
        count += 1
    x += 1
    for c in j:
        if h[x] > h[c]:
            count += 1
            break
print(count)

Submission status: Wrong Answer

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

ab = [list(map(lambda x: x -1, map(int, input().split()))) for _ in range(m)]

# 一つづつ展望台を見る必要はなく、道を見て条件に合わないものを除けば良い
ans_list = [True] * n
for i in range(m):
    if h[ab[i][0]] >= h[ab[i][1]]:
        ans_list[ab[i][1]] = False
    elif h[ab[i][0]] <= h[ab[i][1]]:
        ans_list[ab[i][0]] = False
print(sum(ans_list))

Submission status: Wrong Answer

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

ab = [list(map(lambda x: x -1, list(map(int, input().split())))) for _ in range(m)]
print(ab)

# 一つづつ展望台を見る
ans = 0
for i in range(n):
    cnt_flag = True
    for j in ab:
        if i in j:
            if h[i] <= h[list(((set(j))^{i}))[0]]:
                cnt_flag=False
                break
    if cnt_flag:
        ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
n, m = list(map(int, input().split()))
heights = list(map(int, input().split()))
flags = [True] * n
count = 0
for _ in range(m):
  roots = list(map(int, input().split()))
  if heights[roots[0] - 1] > heights[roots[1] - 1]:
    flags[roots[1] - 1] = False
  elif heights[roots[0] - 1] < heights[roots[1] - 1]:
    flags[roots[0] - 1] = False
  else:
    flags[roots[1] - 1] = False
    flags[roots[0] - 1] = False
for flag in flags:
  if flag:
    count += 1

Submission status: Wrong Answer

Solution code:
import copy
n, m =map(int, input().split())  #複数数値入力
list_h=list(map(int, input().split()))  #リスト入力
# 繰り返しリスト入力
a = []
for i in range(m):
    ai = list(map(int, input().split()))  #リスト入力
    a.append(ai)

for i in a:
    i.sort()
a.sort()
a = list(map(list, set(map(tuple, a))))

booler = [True] * n
for i in range(n):
    a_copy = copy.deepcopy(a)
    for j in range(len(a)):
        if i in a_copy[j] :
            a_copy[j].remove(i)
#             print(a_copy)
            if list_h[i] > list_h[a_copy[j][0]-1]:
                continue
            else:
                booler[i] = False
        else:
            continue

print(booler.count(True))

Submission status: Wrong Answer

Solution code:
import copy
n, m =map(int, input().split())  #複数数値入力
list_h=list(map(int, input().split()))  #リスト入力
# 繰り返しリスト入力
a = []
for i in range(m):
    ai = list(map(int, input().split()))  #リスト入力
    a.append(ai)

booler = [True] * n
for i in range(n):
    a_copy = copy.deepcopy(a)
    for j in range(m):
        if i in a_copy[j] :
            a_copy[j].remove(i)
#             print(a_copy)
            if list_h[i] > list_h[a_copy[j][0]-1]:
                continue
            else:
                booler[i] = False
        else:
            continue

print(booler.count(True))