Problem:


Score : 300 points

Problem Statement

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

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

How many good observatories are there?

Constraints

2 \leq N \leq 10^5

1 \leq M \leq 10^5

1 \leq H_i \leq 10^9

1 \leq A_i,B_i \leq N

A_i \neq B_i

Multiple roads may connect the same pair of observatories.

All values in input are integers.

Input

Input is given from Standard Input in the following format:

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

Output

Print the number of good observatories.

Sample Input 1

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

Sample Output 1

2

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

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

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

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

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

Sample Input 2

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

Sample Output 2

3



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


Sample output:
2

Submission status: Wrong Answer

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

ans = []
for i in range(M):
    A, B = map(int, input().split())
    ans = [max(H[A-1], H[B-1]) if i == H[A-1] else i for i in ans]
    ans = [max(H[A-1], H[B-1]) if i == H[B-1] else i for i in ans]
    ans.append(max(H[A-1], H[B-1])) # 大きい方を入れる
print(set(ans))

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

good = set()
for i in range(m):
    good.add(max(a[i], b[i]))
    
print(len(good))

Submission status: Wrong Answer

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

anslist = [] * M

for _ in range(M):
    a,b = list(map(int, input().split()))
    if a > b:
        anslist.append(a)
    else:
        anslist.append(b)

nums_unique = list(set(anslist))
print(len(nums_unique))

Submission status: Wrong Answer

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

count = 0
bad = []
for i in range(M):
    A, B = map(int, input().split())
    if H[A-1] >= H[B-1]:
        if not B in bad:
            bad.append(B)
            count += 1
    else:
        if not A in bad:
            bad.append(A)
            count += 1

print(N - count)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
H = list(map(int,input().split()))
datas = []
anss = []
for i in range(M):
    datas.append(list(map(int,input().split())))
for data in datas:
    ans = []
    for dat in data:
        ans.append(H[dat-1]) 
    anss.append(max(ans))
print(len(set(anss)))

Submission status: Wrong Answer

Solution code:
import numpy as np

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

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

print(np.sum(ans == 1))

Submission status: Wrong Answer

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

ans = [0] * (n)
route = [0] * (n)
for i in range(len(ab)):
    a, b = ab[i]
    if H[a-1] > H[b-1]:
      ans[a-1] += 1
      ans[b-1] -= 1

    elif H[b-1] > H[a-1]:
      ans[b-1] += 1
      ans[a-1] -= 1
      
    route[a-1]+=1
    route[b-1]+=1

cnt = 0
for i in range(len(route)):
  if route[i] == 0 or ans[i] > 0:
    cnt += 1
    
print(cnt)

Submission status: Wrong Answer

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

lst = [0 for i in range(N)]

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

print(lst.count(0))

Submission status: Wrong Answer

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

J=[0]*N
for i in range(M):
    if H[AB[i][0]-1]<H[AB[i][1]-1]:
        J[AB[i][0]-1]+=1
    else:
        J[AB[i][1]-1]+=1
c=0
for i in J:
    if i == 0:
        c+=1

print(c)

Submission status: Wrong Answer

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

ans = [[i] for i in h]

for i in path:
    ans[i[0]-1].append(h[i[1]-1])
    ans[i[1]-1].append(h[i[0]-1])


count = 0
for i in ans:
    if i[0] == max(i):
      if len(set(i))!=1 or len(i)==1:
        count += 1

print(count)

Submission status: Wrong Answer

Solution code:
road = dict()

N, M = [int(i) for i in input().split()]
peaks = [int(i) for i in input().split()]

def init_road(M, road):
    for _ in range(M):
        a, b = [int(i) for i in input().split()]
        road.setdefault(a,set())
        road.setdefault(b,set())
        road[a].add(b)
        road[b].add(a)
    return road

def good_peak_cnt(road):
    cnt = 0
    for key, values in road.items():
        key_height = peaks[key-1]
        flag = True
        for v in values:
            v_height = peaks[v-1]
            if v_height >= key_height:
                flag = False
                break
        if flag :
            cnt += 1
    return cnt
        
road = init_road(M,road)
good_peaks = good_peak_cnt(road)

print(good_peaks)

Submission status: Wrong Answer

Solution code:
#! python3

def main():
    n, m = map(int, input().split())
    hlist = list(map(int, input().split()))
    tenbou_set = set(range(1, (n+1)))
    for i in range(m):
        a, b = map(int, input().split())
        if hlist[a-1] < hlist[b-1]:
            tenbou_set.discard(a)
        elif hlist[a-1] > hlist[b-1]:
            tenbou_set.discard(b)

    print(len(tenbou_set))

main()

Submission status: Wrong Answer

Solution code:
def solve():
    N,M = map(int, input().split())
    H = list(map(int, input().split()))
    AB = [map(int, input().split()) for _ in range(M)]

    cond = [True]*N
    graph = [[] for _1 in range(N)]
    for a,b in AB:
        graph[a-1].append(b)
        graph[b-1].append(a)
    ans = 0

    for i in range(N):
        hight = H[i-1]
        for j in graph[i]:
            if hight <= H[j-1]:
                break
        else:
            ans += 1
    print(ans)

if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

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

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

tower=[0]*N

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 0
for i in range(len(ki)):
    if len(ki[i]) == 0:
        ans += 1
    else:
        for j in range(len(ki[i])):
            if h[i] > h[ki[i][j]]:
                ans += 1
                break
                
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
H = list(map(int, input().split()))
AB = []
cnt = 0
for i in range(m):
    a, b = map(int, input().split())
    ab = [a, b]
    if ab in AB:
        pass
    else:
        AB.append(ab)

candidate = []
appear = []
div = 0
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)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
H = [int(x) for x in input().split()]
AB = [[int(x) for x in input().split()]for i in range(M)]
good = [-1]*N   
for j in range(M):
  if H[AB[j][0]-1] > H[AB[j][1]-1]:
    good[AB[j][0]-1] = 1
    good[AB[j][1]-1] = 0
  elif H[AB[j][0]-1] < H[AB[j][1]-1]:
    good[AB[j][0]-1] = 0
    good[AB[j][1]-1] = 1
  else:
    good[AB[j][0]-1] = 0
    good[AB[j][1]-1] = 0
print(good.count(-1)+good.count(1))

Submission status: Wrong Answer

Solution code:
import sys
from math import sqrt
from collections import Counter, defaultdict, deque

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)


def I():
    return int(input())


def MI():
    return map(int, input().split())


def LI():
    return list(MI())


def LIN(n: int):
    return [I() for _ in range(n)]


inf = float("inf")
mod = 10 ** 9 + 7


def main():
    n, m = MI()
    h = LI()
    li = [LI() for _ in range(m)]

    dict = defaultdict(list)
    for ab in li:
        dict[ab[0]].append(ab[1])
        dict[ab[1]].append(ab[0])

    towers = list(range(1, n + 1))
    for k, v in dict.items():
        for t in v:
            if h[t - 1] >= h[k - 1]:
                towers.remove(k)
                break

    print(n - len(towers))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def io():
    return map(int,input().split())
def op():
    return list(map(int,input().split()))
n,k=io()
l=op()
c=0
s=set()
s1=set()
for _ in range(k):
    a,b=io()
    s1.update((a,b))
    a-=1
    b-=1
    if l[a]>l[b]:
        s.add(a)
        if b in s:
            s.remove(b)
    elif l[a]<l[b]:
        s.add(b)
        if a in s:
            s.remove(a)
c+=n-len(s1)
print(len(s)+c)

Submission status: Wrong Answer

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

dp=[True]*N

for i in A:
  if H[i[0]-1]<H[i[1]-1]:
    dp[i[1]-1]=True
    dp[i[0]-1]=False
  elif H[i[0]-1]>H[i[1]-1]:
    dp[i[1]-1]=False
    dp[i[0]-1]=True
  elif H[i[0]-1]==H[i[1]-1]:
    dp[i[1]-1]=True
    dp[i[0]-1]=True

print(dp.count(True))

Submission status: Wrong Answer

Solution code:
from math import factorial as fact
import math
import sys
import itertools
import numpy as np
from collections import Counter
import datetime


#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

def keta(N):
	return len(str(N))


def input_daytime(input_time):
	time,distance=input_time.split()
	t=time.split(":")
	se=str(t[-1]).split(".")
	dt1 = datetime.timedelta(hours=int(t[0]),minutes=int(t[1]),seconds=int(se[0]),milliseconds=int(se[1]))
	return dt1

def combinations(n,r):
	return list(itertools.combinations(range(n),r))



def all_sets(num_list):
	subsets=[]
	for i in range(2,len(num_list) + 1):
		for c in combinations(num_list, i):
			subsets.append(c) 
	return subsets

#公約数の列挙
def ch(x1):
	cf=[]
	for i in range(2,math.sqrt(x1)+1):
		if x1 % i==0:
			cf.append(i)
	return cf

def CountOneRoots(x,y):
	#x:縦，y:横
	return fact(x+y)/fact(x)/fact(y)

# 素因数分解
def factorization(n):
	tmp=n
	count=0
	for i in range(2,int(n**0.5)+2):
		if tmp%i==0:
			cnt=0
			while tmp%i==0:
				cnt+=1
				tmp//=i
			count+=1
	if tmp!=1:
		count+=1

	return count
			


n,m=input2()
H=input_array()
# G=[[0]*n]*n #グラフ
counts=[]
l=[]
for i in range(m):
	a,b=input2()
	l+=[a,b]
	if H[a-1]>H[b-1]:
		counts.append(a-1)
		if b-1 in counts:
			counts.remove(b-1)
	elif H[a-1]<H[b-1]:
		counts.append(b-1)
		if a-1 in counts:
			counts.remove(a-1)

ones=n-len(Counter(l)) #単独

print(len(Counter(counts)) + ones)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
h=[int(i)for i in input().split()]
j=[]
c=0
d=0
for i in range(m):
    t=input().split()
    j.append([int(t[0]),int(t[1])])
for i in range(n):
    d=0
    for s in range(m):
        if h[i]in j[s]:
            d+=1
            if min(j[s])!=h[i]:
                c+=1
                break
    if d==0:
        c+=1
print(c)

Submission status: Wrong Answer

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


ans = [[] for i in range(n)]
for i in range(m):
  a, b= map(int, input().split())
  ans[a-1].append(b-1)
  ans[b-1].append(a-1)
  
route = [[] for i in range(n)]
for i in range(n):
  for j in ans[i]:
    route[i].extend(ans[j])
  route[i] = set(route[i])

count = 0
for i in range(n):
  flag = True
  for j in route[i]:
    if h[i] < h[j]:
      flag = False
  if flag:
    count+=1

print(count)

Submission status: Wrong Answer

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

ans_set = set()
used_set = set()
for ab in ab_list:
    a = ab[0] - 1
    b = ab[1] - 1

    used_set.add(a)
    used_set.add(b)

    if h_list[a] == h_list[b]:
        continue
    win = a if h_list[a] > h_list[b] else b
    ans_set.add(win)

# print(used_set)
for i in range(len(h_list)):
    if not(i in used_set):
        ans_set.add(i)
# print(ans_set)
print(len(ans_set))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys


def input():
    return sys.stdin.readline()


def resolve():
    n, m = map(int, input().split())
    h_list = list(map(int, input().split()))
    a_list = []
    b_list = []
    ans_list = [1 for i in range(n)]

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

    count = 0
    for i in ans_list:
        if i == 1:
            count += 1

    print(count)




if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
n,m=list(map(int, input().split()))
h=list(map(int, input().split()))
p=[]
remain = set(range(1, n+1))
for i in range(m):
    p.append(list(map(int, input().split())))
#p.sort()
temp = []
for a,b in p:
    temp.append([b,a])
p = p + temp
#p.sort()
#for a,b in p:
#    if not (a in remain):
#        continue
#    if h[a-1]<=h[b-1]:
#        remain = remain - set([a])
print(len(remain))

Submission status: Wrong Answer

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

T = [set() for _ in range(N)]

for _ in range(M):
    a, b = map(int, input().split())
    T[a-1].add(H[b-1])
    T[b-1].add(H[a-1])

count = 0
for i, t in enumerate(T):
    if not t:
        continue
    h = H[i]
    if h >= max(t):
        count += 1

print(count)

Submission status: Wrong Answer

Solution code:


def main():
    N, M = list(map(int, input().split(' ')))
    
    Hn = list(map(int, input().split(' ')))
    
    ABn = []
    for _ in range(M):
        ABn.append(list(map(int, input().split(' '))))
    
    dic_path = {i+1:[] for i in range(len(Hn))}
    
    for i in range(M):
        a = ABn[i][0]
        b = ABn[i][1]
        
        dic_path[a].append([a, b])
        dic_path[b].append([b, a])
    
    
    result = 0
    for i, paths in dic_path.items():
        
        if len(paths) == 0:
            result += 1
            break
        
        
        flag = True
        for path in paths:

            a, b = path[0], path[1]
            ha, hb = Hn[a-1], Hn[b-1]
            
            if ha < hb:
                flag = False
            # print('a, b, ha, hb:', a, b, ha, hb)
            
            # if ha < hb:
            #     break
            # elif ha > hb:
            #     # print('a, b, ha, hb:', a, b, ha, hb)
            #     result += 1
            #     break
        
        if flag is True:
            result += 1
    print(result)
                
                
                
        
        
        
        

        
    
    



main()

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

good = [1] * (n+1)


for i in a:
    if h[i[0]-1] < h[i[1]-1]:
        good[i[0]] = 0
    else:
        good[i[1]] = 0

print(good.count(1)-1)

Submission status: Wrong Answer

Solution code:
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n)]
        self.size = [1]*n

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

    def unite(self,a,b):
        a_root = self.find(a)
        b_root = self.find(b)
        if a_root == b_root:
            return
        else:
            if self.size_of(b_root) > self.size_of(a_root): 
                self.parent[a_root] = self.parent[b_root]
                self.size[b_root] += self.size[a_root]
            else:
                self.parent[b_root] = self.parent[a_root]
                self.size[a_root] += self.size[b_root]
                
    def size_of(self,a):
        return self.size[self.find(a)]
    
    def is_same(self,a,b):
        return self.find(a) == self.find(b)


N,K = map(int,input().split())
input()
uf = UnionFind(N)
for _ in range(K):
    a,b = map(int,input().split())
    uf.unite(a-1,b-1)
print(len(set(uf.size)))

Submission status: Wrong Answer

Solution code:
n,m=map(int, input().split())
h=list(map(int, input().split()))
dic = {}
ng = set()

for i in range(m):
  a,b=map(int, input().split())
  if h[a-1] > h[b-1]:
    if not a in ng:
      dic[str(a)] = h[a-1]
    ng.add(b)
    if str(b) in dic:
      dic.pop(str(b))
  else:
    if not b in ng:
      dic[str(b)] = h[b-1]
    ng.add(a)
    if str(a) in dic:
      dic.pop(str(a))
    
print(len(dic))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
H = [ int(x) for x in input().split()]
li = []
for i in range(M):
    A,B = map(int,input().split())
    li.append(int(max(H[A-1],H[B-1]))) 
    
print(len(set(li)))

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())  #N個の展望台,M本の道

H_list = [int(x) for x in input().split()]

answer_list = [0 for _ in range(N)]

for i in range(M):
    B = [int(x) for x in input().split()]
    #print(B)
    
    if H_list[B[0]-1] < H_list[B[1]-1]:
        answer_list[B[0]-1] += 1
    else:
        answer_list[B[1]-1] += 1
cnt = 0
for j in range(N):
    if answer_list[j] == 0 :
        cnt += 1
    
print(cnt)

Submission status: Wrong Answer

Solution code:
# N が展望台の数
# M が展望台を結ぶ道の数
N, M = list(map(int, input().split()))

# 展望台の標高
H = list(map(int, input().split()))

# 各展望台ごと周辺で一番大きな展望台の高さ
highest = [True] * N

res = 0

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

  a = a - 1
  b = b - 1

  highest[a] = H[a] > H[b]
  highest[b] = H[a] < H[b]

for i, value in enumerate(highest):
  if(highest[i]):
    res += 1

print(res)

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
h = input().split()
e = [1]*n
ans = 0

for i in range(n):
  h[i] = int(h[i])
#
#print(h)

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

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

Submission status: Wrong Answer

Solution code:
mod = 10**9+7
import sys
from collections import Counter, defaultdict, deque
from itertools import product, permutations, combinations, combinations_with_replacement
from itertools import accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from math import ceil,floor
from copy import deepcopy
from heapq import heappop,heappush,heapify
import heapq


# l = ['a', 'a', 'a', 'a', 'b', 'c', 'c']
# c = Counter(l)

# d = defaultdict(int)

sys.setrecursionlimit(10 ** 6)

int1 = lambda x: int(x) - 1

# リストの要素を改行を挟んで表示する
p2D = lambda x: print(*x, sep="\n")
# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())

def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())

# 入力全てを整数に変換したものの配列を受け取る
# def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI(): return list(map(lambda x:int(x), sys.stdin.readline().split()))
def HI(): return list(map(lambda x:int(x)*(-1), sys.stdin.readline().split()))


n,m = MI()
h = LI()
a = []

d = defaultdict(int)
for _ in range(m):
	aa,bb = MI()
	d[(aa-1)] = max(d[bb-1],d[(aa-1)])
	d[(bb-1)] = max(d[bb-1],d[(aa-1)])
	if h[aa-1]>=h[bb-1]:
		a.append(bb)
	elif h[bb-1]>=h[aa-1]:
		a.append(aa)

print(n-len(set(a)))
# ans=0
# for i in range(n):
# 	if h[i]<=d[i]:
# 		ans += 0
# 	else:
# 		ans += 1
	# tmp = d[str(h[i])]
	# k = 1
	# if len(tmp)>0:
	# 	tmp = [int(s) for s in tmp.split(':') if not s=='']
	# 	for s in tmp:
	# 		if int(h[i])<=s:
	# 			k = 0
	# ans+=k
# print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N, M = map(int, input().split())
H = list(map(int, input().split()))
lst = [list(map(int, input().split())) for _ in range(M)]

# print(N, M)
# print("H", H)
# print("lst", lst)
a = set()
b = set()
c = set(H)
# print('c: ', c)
for i in lst:
    if H[i[0]-1] < H[i[1]-1]:
        a.add(i[1]-1)
        # print("H:", H[i[1]-1], H[i[0]-1])
        b.add(i[0]-1)
    elif H[i[0]-1] == H[i[1]-1]:
        b.add(i[0]-1)
        b.add(i[1]-1)
        # print("S:", H[i[1]-1], H[i[0]-1])
    else:
        a.add(i[0]-1)
        b.add(i[1]-1)
        # print("L:", H[i[0]-1], H[i[1]-1])

# print('a', a)
# print('b', b)
print(len(c - a))

Submission status: Wrong Answer

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

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

print(N - len(bad))

Submission status: Wrong Answer

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

hList = [int(x) for x in input().split()]

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

for i in range(m):
    a, b = map(int, input().split())
    if hList[a - 1] == hList[b - 1]:
        tenboudai[a - 1] = 0
        tenboudai[b - 1] = 0
    elif hList[a - 1] > hList[b - 1]:
        tenboudai[b - 1] = a - 1
    else:
        tenboudai[a - 1] = b - 1

ans = 0
for i in tenboudai:
    if i == 1:
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
h_list = list(map(int,input().split()))
roads = []
for i in range(m):
    a,b = map(int,input().split())
    roads.append([a,b])
#print(roads)
terrace = [1] * n
for road in roads:
    if h_list[road[0]-1] > h_list[road[1]-1] and h_list[road[0]-1] != 0:
        terrace[road[0]-1] = 1
        terrace[road[1]-1] = 0
    elif h_list[road[0]-1] == h_list[road[1]-1]:
        terrace[road[0]-1] = 0
        terrace[road[1]-1] = 0
    elif h_list[road[0]-1] < h_list[road[1]-1] and h_list[road[1]-1] != 0:
        terrace[road[0]-1] = 0
        terrace[road[1]-1] = 1
print(terrace.count(1))

Submission status: Wrong Answer

Solution code:
N, K = map(int,input().split())
H = list(map(int,input().split()))
s = {}
for j in range(K):
  A, B = map(int,input().split())
  if H[A-1] < H[B-1]:
    s[A] = False
    s[B] = True
  else:
    s[A] = True
    s[B] = False
    
cnt = 0
for i in s:
  if s[i]:
    cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
lis1 = list(map(int, input().split()))
ans = []
for i in range(n):
    ans.append(1)

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

print(sum(ans))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
n, m = map(int, input().split())
*h, = map(int, input().split())
h = [0] + h
i = [0] + [1] * n

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

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
h = list(map(int,input().split()))
route = []
lower = []
cnt = 0
for i in range (m):
    s = list(map(int,input().split()))
    route.append(s)
for i in range(len(route)):
    a =route[i][0]-1
    b =route[i][1]-1
    if h[a]>=h[b]:
        lower.append(b+1)
    elif h[b]>=h[a]:
        lower.append(a+1)
low = list(set(lower))
print(low)
for i in range(1,n+1):
    if i not in low:
        cnt += 1
print(cnt)

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())
s = [0]*m
count = 0
sw = [0]*n
for i in range(m):
    if  h[a[i]-1] >= h[b[i]-1] and sw[a[i]-1] == 0:
        count += 1
        sw[a[i]-1] = 1
    elif h[a[i]-1] < h[b[i]-1] and sw[b[i]-1] == 0:
        count += 1
        sw[b[i]-1] = 1
print(count)

Submission status: Wrong Answer

Solution code:
N,M = map(int, input().split())
H = list(map(int, input().split()))
A = []
B = []
good = [1]*N
for i in range(M):
    a,b = map(int, input().split())
    if H[a-1] == H[b-1]:
        good[a-1] = 0
        good[b-1] = 0
    else:
        temp = min(H[a-1],H[b-1])
        good[H.index(temp)] = 0
print(good.count(1))

Submission status: Wrong Answer

Solution code:
s = input()

N = int(s.split()[0])
M = int(s.split()[1])

H = input().split()

tenbo = []
for i in range(N):
  tenbo.append(i+1)

for i in range(M):
  road = input().split()
  A = int(road[0])
  B = int(road[1])
  HA = int(H[A-1])
  HB = int(H[B-1])
  if HA > HB and B in tenbo:
    tenbo.remove(B)
  if HA < HB and A in tenbo:
    tenbo.remove(A)
    
print(len(tenbo))

Submission status: Wrong Answer

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

num = input().split(" ")

h = input().split(" ")

counter = [True for i in range(int(num[0]))]

for i in range(int(num[1])):
    ab = input().split(" ")
    a = int(ab[0])-1
    b = int(ab[1])-1
    if a != b:
        if h[a] > h[b]:
            counter[b] = False
        elif h[a] < h[b]:
            counter[a] = False
        elif h[a] == h[b]:
            counter[a] = False
            counter[b] = False
        
print(counter.count(True))

Submission status: Wrong Answer

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

A = []
B = []

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

ans = 0
for i in range(N):
  flag = 0
  L = [i for i, x in enumerate(A) if x == (i+1)]
  for j in range(len(L)):
    if H[i] < B[L[j]]:
      flag += 1
  if flag == 0:
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
road = dict()

N, M = [int(i) for i in input().split()]
peaks = [int(i) for i in input().split()]

def init_road(M, road):
    for _ in range(M):
        a, b = [int(i) for i in input().split()]
        road.setdefault(a,set())
        road.setdefault(b,set())
        road[a].add(b)
        road[b].add(a)
    return road

def good_peak_cnt(road):
    cnt = 0
    for key, values in road.items():
        key_height = peaks[key-1]
        flag = True
        for v in values:
            v_height = peaks[v-1]
            if v_height > key_height:
                flag = False
                break
        if flag :
            cnt += 1
    return cnt
        
road = init_road(M,road)
good_peaks = good_peak_cnt(road)

print(good_peaks)

Submission status: Wrong Answer

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


def solve(N: int, M: int, H: "List[int]", A: "List[int]", B: "List[int]"):
    mountains = {i:'WIN' for i in range(N)}
    for road in range(M):
        if H[A[road]] < H [B[road]]:
            mountains[A[road]] = 'LOSE'
        elif H[A[road]] == H[B[road]]:
            mountains[A[road]] = 'LOSE'
            mountains[B[road]] = 'LOSE'
    count = 0
    for i in range(N):
        if mountains[i] == 'WIN':
            count += 1
    print(count)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    H = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    A = [int()] * (M)  # type: "List[int]"
    B = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        A[i] = int(next(tokens)) - 1
        B[i] = int(next(tokens)) - 1
    solve(N, M, H, A, B)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N,M = map(int, input().split())
H = list(map(int, input().split()))
loadJ = []
count = 0
for i in range(M):
    loadJ.append(list(map(int, input().split())))
for i,value in enumerate(H):
    status = True
    for aLoad in loadJ:
        if (aLoad[0] == i and i <= H[aLoad[1] - 1]) or (aLoad[1] == i and i <= H[aLoad[0] - 1]):
            status = False
    if status == True:
        count += 1
print(count)