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()))
A = []
B = []
ans = [1 for i in range(N)]
for i in range(M): 
    a, b = map(int, input().split())
    if H[a-1] < H[b-1]:
        # print()
        # print("bad")
        # print(str(a))
        ans[a-1] = 0
    else:
        ans[b-1] = 0

print(sum(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 = []
b = []
d = defaultdict(str)
for _ in range(m):
	aa,bb = MI()
	d[str(aa-1)] += ':'+str(h[bb-1])
	d[str(bb-1)] += ':'+str(h[aa-1])
ans=0
for i in range(n):
	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:
n,m= map(int, input().split())
h= list(map(int, input().split()))
ab= [list(map(int, input().split())) for _ in range(m)]
flags=[True]*n

for i in range(m):
    if h[ab[i][0]-1]>h[ab[i][1]-1]:
        flags[ab[i][0]-1]=False
    else:
        flags[ab[i][1]-1]=False
print(flags.count(True))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
h_array = [int(x) for x in input().split()]
higest = [True for x in range(n)]
res = 0
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if h_array[a] >= h_array[b]:
        higest[b] = False
    elif h_array[b] >= h_array[a]:
        higest[a] = False

print(higest.count(True))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    n, m = LI()
    h = LI()
    ab = LIR_(m)
    ans = [1] * n
    for a, b in ab:
        if h[a] < h[b]:
            ans[a] = 0
        if h[b] < h[a]:
            ans[b] = 0
    print(sum(ans))
    return


#main
if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

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

tmp = [0 for _ in range(N)]
for i in range(M):
  if H[Q[i][0]-1] >= H[Q[i][1]-1]:
    tmp[Q[i][1]-1] = -1
  elif H[Q[i][0]-1]<= H[Q[i][1]-1]:
    tmp[Q[i][0]-1] = -1

print(N + sum(tmp))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
H_ = list(map(int,input().split()))
H = [0]
H.extend(H_)
R = set()
ret = set()
for i in range(M):
    temp_ = list(map(int,input().split()))
    if H[temp_[0]] > H[temp_[1]]:
        ret.add(temp_[0])
        if temp_[1] in ret:
            ret.remove(temp_[1])
    elif H[temp_[1]] > H[temp_[0]]:
        ret.add(temp_[1])
        if temp_[0] in ret:
            ret.remove(temp_[0])
    R.add(temp_[0])
    R.add(temp_[1])
num = len(ret)
num += N - len(R)
print(num)

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 _ in range(M)]

li = [0] + [-1] * N
for a, b in AB:
    ma = max(H[a-1], H[b-1])
    if ma==H[a-1]:
        li[a]=1
        li[b]=-2
    else:
        li[a]=-2
        li[b]=1

cnt=0

for i in range(N+1):
    if i==0:
        continue
    if li[i]==1 or li[i]==-1:
        cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
ma = lambda :map(int,input().split())
ni = lambda:int(input())

n,m = ma()
H = list(ma())
ab = []
tr = [[] for i in range(n)]
for i in range(m):
    a,b = ma()
    tr[a-1].append(b-1)
    tr[b-1].append(a-1)
vis = [False]*n
gb = [False]*n
ans = 0
for i in range(n):
    if not vis[i]:
        f = True
        h = H[i]
        c = 1
        for node in tr[i]:
            vis[node] = True
            if H[node] ==h:
                c+=1
            elif H[node] > h:
                h = H[node]
                c = 1
        if c==1:ans+=1
print(ans)

Submission status: Wrong Answer

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

dame_set = set()

for item in ab_list:
    if h_list[item[0]-1] >= h_list[item[1]-1]:
        dame_set.add(item[1]-1)
    elif h_list[item[0]-1] <= h_list[item[1]-1]:
        dame_set.add(item[0]-1)

print(n - len(dame_set))

Submission status: Wrong Answer

Solution code:
from sys import stdin
from collections import defaultdict
N,M = [int(x) for x in stdin.readline().rstrip().split()]
H = [int(x) for x in stdin.readline().rstrip().split()]
d = defaultdict(set)
for i in range(M):
    A,B = [int(x) for x in stdin.readline().rstrip().split()]
    d[A].add(B)
    d[B].add(A)
    
ans = 0
for h in range(1,N+1):
    f = True
    for i in d[h]:
        if H[i-1] > H[h-1]:
            f = False
    if f:
        ans += 1
print(ans)

Submission status: Wrong Answer

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

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

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

par = set(par)
print(len(par))

Submission status: Wrong Answer

Solution code:

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


visited = [0]*N
for i in range(M):
    a,b = map(int,input().split())
    visited[a-1] = 1
    visited[b-1] = 1
    if H[a-1]<H[b-1]:
        ans[a-1] = -1
    elif H[b-1]<H[a-1]:
        ans[b-1] = -1


ans = [i for i in range(N) if ans[i]==0 and visited[i]==1]
print(len(ans))

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
arr=[int(i) for i in input().split()]
hashmap=dict()
count=dict()
for key in range(1,n+1):
  hashmap[key]=arr[key-1]
  count[key]=0

result=0
for i in range(m):
  a,b=map(int,input().split())
  if hashmap[a]<hashmap[b]:
    count[a]+=1
for i in range(1,n+1):
  if count[i]==0:
    result+=1
    
print(result)

Submission status: Wrong Answer

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

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

cnt = 0
for i in l:
  if i == 1:
    cnt += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
from collections import deque
import sys
sys.setrecursionlimit(10**7)

N,M=map(int,input().split())
H=list(map(int,input().split()))
road=[[] for i in range(N)]
toutatu=[0]*N
for i in range(M):
  a,b=map(int,input().split())
  road[a-1].append(b-1)
  road[b-1].append(a-1)
print(road)

q=deque([])

def dfs(q,h):
  while(q):
    v=q.popleft()
    for x in road[v]:
      if(toutatu[x]==0):
        q.append(x)
        h=max(h,H[x])
        toutatu[x]=1
        dfs(q,h)
        
  return h
count=0
for i in range(N):
  if(toutatu[i]==0):
    q.append(i)
    count+=1
    h=0
    dfs(q,h)
print(count+1)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
h = list(map(int,input().split()))
l = [tuple(map(int,input().split())) for i in range(m)]
x = ["X"]*n
for t in l:
    if h[t[0]-1] <= h[t[1]-1]:
        x[t[1]-1]="G"
        x[t[0]-1]="B"
    elif h[t[0]-1] >= h[t[1]-1]:
        x[t[1]-1]="B"
        x[t[0]-1]="G"
print(x.count("G"))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# Problem C - Peaks

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

# initialization
score_list = [0]*N
for i in range(M):
    a, b = map(int, input().split())
    if h_list[a-1]<h_list[b-1]:
        if h_list[b-1]>=0:
            score_list[b-1] += 1
        else:
            score_list[b-1] -= 1
        score_list[a-1] -= 1
    elif h_list[a-1]>h_list[b-1]:
        if h_list[a-1]>=0:
            score_list[a-1] += 1
        else:
            score_list[a-1] -= 1
        score_list[b-1] -= 1
    else:
        score_list[a-1] -= 1
        score_list[b-1] -= 1

# output
ans = 0
for s in score_list:
    if s>=0:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split(" "))
H = input().split(" ")
OK = [0]*len(H)
for i in range(len(H)):
  H[i]=int(H[i])
  OK[i]=H[i]
for j in range(M):
  A,B = map(int,input().split(" "))
  if min(H[A-1],H[B-1]) in OK:
    OK.remove(min(H[A-1],H[B-1]))
print(len(OK))

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

a=[1]*n
for i in range(m):
    if h[ab[i][0]-1]<h[ab[i][1]-1]:
        a[ab[i][1]-1]=0
    else:
        a[ab[i][0]-1]=0
print(sum(a))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
H = list(map(int, input().split()))
d = H[:]
L = []
for _ in range(M):
    a, b = map(int, input().split())
    m = max(d[a - 1], d[b - 1])
    d[a - 1], d[b - 1] = m, m

print(len(set(d)))

Submission status: Wrong Answer

Solution code:
n, m = (int(x) for x in input().split())
list_h = list(map(int, input().split()))
list_n =[[-1 for i in range(1)] for j in range(n)]
count=0
for i in range(m):
    a,b = (int(x) for x in input().split())
    if list_n[a-1]==-1:
        list_n[a-1]=b
    else:
        list_n[a-1].append(b)
    if list_n[b-1]==-1:
        list_n[b-1]=a
    else:
        list_n[b-1].append(a)
for i in range(n):
    boo = True
    h = list_h[i]
    for j in range(len(list_n[i])):
        k = list_n[i][j]
        if h<list_h[k-1]:
            boo=False
    if boo:
        count+=1
print(count)

Submission status: Wrong Answer

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



ans_set = set()
appear_set = set()

for i in range(M):
    a, b = AB[i]
    if H[a-1] > H[b-1]:
        ans_set.add(a)
    elif H[a-1] < H[b-1]:
        ans_set.add(b)
    else:
        pass

    appear_set.add(a)
    appear_set.add(b)

ans_set = ans_set.union(set(range(1, N+1)) - appear_set)
print(len(ans_set))

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
h=list(map(int,input().split())) #高さ
A=[]
for i in range(m):
    a,b=map(int,input().split())
    if h[a-1]>h[b-1]:
        A.append(h[a-1])
    else:
        A.append(h[b-1])
print(len(set(A)))

Submission status: Wrong Answer

Solution code:
nm = input().split()
n = int(nm[0])
m = int(nm[1])
h = input().split()
r = [1] * len(h)
for i in range(m):
	ab = input().split()
	a = int(ab[0])
	b = int(ab[1])

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

cnt = 0

for i in r:
	if int(i) == 1:
		cnt += 1

print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
N,K=map(int,input().split())
L=list(map(int,input().split()))
Hash=defaultdict(lambda:list())
for i in range(K):
    x,y=map(int,input().split())
    Hash[L[x-1]].append(L[y-1])
    Hash[L[y-1]].append(L[x-1])
count=0
for i in L:
    if len(Hash[i])==0:
        count+=1
    else:
        FLAG=0
        for j in Hash[i]:
            if j>i:
                FLAG=1
                break
        if FLAG==0:
            count+=1
print(count)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
H=[-1]
H.extend(list(map(int,input().split())))

left=[]
st = set()

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

    if H[A]<H[B]:
        if A in left:
            n = left.index(A)
            left.pop(n)
        if not B in left:
            left.append(B)

    elif H[A]>H[B]:
        if  B in left:
            n = left.index(B)
            left.pop(n)
        if not A in left:
            left.append(A)

    elif H[A]==H[B]:
        if A in left:
            n = left.index(A)
            left.pop(n)
        if B in left:
            n = left.index(B)
            left.pop(n)

st = list(st)

print(len(left)+N-len(st))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n, m = map(int, input().split())
h = list(map(int, input().split()))
route = [[0 for i in range(n)] for i in range(n)]
h_cond = [True]*n
count = 0

for i in range(m):
    tmp_a, tmp_b = map(int, input().split())
    route[tmp_a-1].append(tmp_b)
    route[tmp_b-1].append(tmp_a)
    if h[tmp_a-1] < h[tmp_b-1]:
        h_cond[tmp_a-1] = False
    else:
        h_cond[tmp_b-1] = False

# print(h_cond)
# print(route)
for idx, ri in enumerate(route):
    if len(ri) == 0:
        count += 1
    else:
        if h_cond[idx]:
            count += 1

print(count)

Submission status: Wrong Answer

Solution code:
from bisect import *
N,M = map(int,input().split())
H = list(map(int,input().split()))
AB = [[] for _ in range(N)]
count = 0
for _ in range(M):
  a,b = map(int,input().split())
  AB[a-1].append(H[b-1])
  AB[b-1].append(H[a-1])
for i in range(N):
  if AB[i] == []:
    count += 1
  elif H[i] > AB[i][-1]:
    count += 1
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
  n, m = map(int, input().split())
  H = list(map(int, input().split()))
  set_tmp = set()
  for i in range(m):
    a, b = map(int, input().split())
    if H[a-1] > H[b-1]:
      set_tmp.add(b)
    if H[a-1] == H[b-1]:
      set_tmp.add(a)
      set_tmp.add(b)
    else:
      set_tmp.add(a)
  print(n - len(set_tmp))
  
  
if __name__ == '__main__':
  main()

Submission status: Wrong Answer

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

goodpoint = [1]*N #1 is good point

for i in range (M):
    A, B = map(int,input().split())
    if H[A-1] <=H[B-1]:
        goodpoint[A-1] = 0
    if H[B-1] <=H[A-1]:
        goodpoint[B-1] = 0
print(sum((np.array(goodpoint)==0)*1))

Submission status: Wrong Answer

Solution code:
N, M = [int(i) for i in input().split()]
H = [None] + [int(i) for i in input().split()]
ANS = [True] * (N + 1)
ANS[0] = False
for i in range(M):
    A, B = [int(i) for i in input().split()]
    if H[A] >= H[B]:
        ANS[B] = False
    if H[B] > H[A]:
        ANS[A] = False
ans = 0
for i in ANS:
    if i:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

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

hts = [int(el) for el in input().split()]
heights = {}
for i, val in enumerate(hts, start=1):
    heights[i] = val

routes = defaultdict(lambda: set())
for _ in range(M):
    s, d = [int(el) for el in input().split()]
    routes[s].add(d)
    routes[d].add(s)

gd = 0
for src, destinations in routes.items():
    good = True
    for dest in destinations:
        if heights[src] < heights[dest]:
            good = False
    if good:
        gd += 1
print(gd)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
h=list(map(int,input().split()))
ll=[]
for i in range(m):
    a,b=map(int,input().split())
    if h[a-1]<h[b-1]:
        lose=a
    elif h[a-1]>h[b-1]:
        lose=b
    else:
        lose=a,b
    ll.append(lose)
import collections
c=collections.Counter(ll)
print(n-len(c))

Submission status: Wrong Answer

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

res=[1]*n
for i in range(m):
    if(h[a[i][0]-1]<h[a[i][1]-1]):
        res[a[i][0]-1]=0
    else:
        res[a[i][1]-1]=0
ans=0
for i in range(n):
    if(res[i]==1):
        ans+=1
print(ans)

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())
    if h[A-1]>=h[B-1]:
        ans.append(A-1)
    else:
        ans.append(B-1)
print(len(set(ans)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
h=input().split()
a=[]
b=[]
for i in range(0,m):
    ay,by=map(int,input().split())
    a.append(ay)
    b.append(by)

#ans=[i+1 for i in range(0,n)]
ans=[]

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

num=len(set(ans))
print(n-num)

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,m=map(int,input().split())
    H=[int(_) for _ in input().split()]
    HH= [[0]*2 for _ in range(n)] 

    for i in range(m):
        a,b=map(int,input().split())
        if HH[a-1][0]==0:
            HH[a-1][0]=H[b-1]
        else:
            HH[a-1][1]=H[b-1]
        if HH[b-1][0]==0:
            HH[b-1][0]=H[a-1]
        else:
            HH[b-1][1]=H[a-1]
    ans=0
    for i,hh in enumerate(HH):
        if H[i]>max(hh) or hh==[0,0]:
            ans+=1

    print(ans)

if __name__=='__main__':
    main()

Submission status: Wrong Answer

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

ans = np.array(list(range(N)))

for _ 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
print(len(ans[ans!=-1]))

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
h=list(map(int,input().split()))
ab=[list(map(int,input().split())) for i in range(m)]
d=[ [] for i in range(n+1)]
for i in range(m):
  #a=ab[i][0]
  #b=ab[i][1]
  d[ab[i][0]].append(h[ab[i][1]-1])
  d[ab[i][1]].append(h[ab[i][0]-1])
count=0
for i in range(1,len(d)-1):
  if len(d[i])!=0 and h[i]<max(d[i]):
    count+=1
print(count)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
H=list(map(int,input().split()))
L=[]
for i in range(M):
  L.append(list(map(int, input().split())))
#print(H,L)
for i in range(M):
  X=H[L[i][0]-1]
  Y=H[L[i][1]-1]
  #print(X,Y)
  if X>Y:
    H[L[i][1]-1]=X
  else:
    H[L[i][0]-1]=Y
ans=len(set(H))
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 _ in range(M)]

li = [0] + [-1] * N
for a, b in AB:
    ma = max(H[a-1], H[b-1])
    if ma==H[a-1]:
        li[a]=1
        li[b]=-1
    else:
        li[a]=-1
        li[b]=1

cnt=0

for i in range(N+1):
    if i==0:
        continue
    if li[i]==1:
        cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
import sys
from math import factorial
from collections import Counter
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
MOD = 10**9 + 7

n, m = MAP()
H = LIST()
low = [0]*m
for i in range(m):
    a, b= MAP()
    if H[a-1] == H[b-1]:
        low.append(a-1)
        low.append(b-1)
    elif H[a-1] < H[b-1]:
        low.append(a-1)
    else:
        low.append(b-1)

print(n-len(set(low)))

Submission status: Wrong Answer

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

print(n-len(s))

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

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

G = [[] for _ in range(N)]
for _ in range(M):
    A, B = map(int, readline().split())
    G[A-1].append(B)
    G[B-1].append(A)

ans = 0
for i, shimas in enumerate(G):
    is_ok = True
    height = H[i-1]
    for shima in shimas:
        if height <= H[shima-1]:
            is_ok = False
            break
    if is_ok:
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque

N, M = map(int, input().split())
H = [int(s) for s in input().split()]

edges = defaultdict(list)

for i in range(M):
    w = 1
    u, v = map(int, input().split())
    edges[u-1].append((v-1, w))
    edges[v-1].append((u-1, w))

# print(edges)

checked = [None] * N
checked[0] = 0

que = deque([0])

while que:
    u = que.popleft()
    c = True
   # print('check u=', u)
    for v, w in edges[u]:
       # print('++++ v=', v)
        if checked[v] != None:
            continue
        if edges[v] != []:
            que.append(v)
        if H[u] <= H[v]:
            c = False
    checked[u] = c

ans = 0
for i in range(N):
    if checked[i] == False or checked[i] == None:
        ans += 1

# print(checked)
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
N,K=map(int,input().split())
L=list(map(int,input().split()))
Hash=defaultdict(lambda:list())
for i in range(K):
    x,y=map(int,input().split())
    Hash[L[x-1]].append(L[y-1])
    Hash[L[y-1]].append(L[x-1])
count=0
for i in L:
    if len(Hash[i])==0:
        count+=1
    else:
        FLAG=0
        for j in Hash[i]:
            if j>=i:
                FLAG=1
                break
        if FLAG==0:
            count+=1
print(count)

Submission status: Wrong Answer

Solution code:
N, M = list(map(int, input().split()))
Hs = list(map(int, input().split()))
flg_list = [0] * N
for j in range(M):
    ai, bi = list(map(int, input().split()))
    ai -= 1
    bi -= 1
    if Hs[ai] > Hs[bi]:
        flg_list[ai] += 1
    else:
        flg_list[bi] += 1

print(flg_list.count(0))

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
H=list(map(int,input().split()))
c=[]
for j in range(N):
  c.append(j+1)
for i in range(M):
  A,B=map(int,input().split())
  if H[A-1]<H[B-1]:
    mini=A
  else:
    mini=B
  if mini in c:
    c.remove(mini)
    
print(len(c))

Submission status: Wrong Answer

Solution code:
s = list(map(int, input().split()))
n = s[0]
m = s[1]

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

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

good = []
for i in range(n):
    good.append(True)

for i in range(m):
    if h[a[i][0] - 1] > h[a[i][1] - 1]:
        good[a[i][1] - 1] = False
    elif h[a[i][0] - 1] < h[a[i][1] - 1]:
        good[a[i][1] - 1] = False
    else:
        good[a[i][1] - 1] = False
        good[a[i][1] - 1] = False

count = 0
for i in range(n):
    if good[i]:
        count = count + 1

print(count)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

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

ab = [tuple(map(int,input().split())) for i in range(m)]
es = [[] for i in range(n)]
for i, (a,b) in enumerate(ab):
    a,b = a-1,b-1
    es[a].append(b)
    es[b].append(a) #無向グラフ

ans = []
for i in range(n):
    ma = h[i]
    tmp = []
    if es[i] == []:
        ans.append(i)
    else:
        for aa in  set(es[i]):
            if ma < h[aa]:
                ma = h[aa]
                tmp = [aa]
            elif ma==h[aa]:
                tmp.append(aa)

        ans = ans + tmp

print(len(set(ans)))

Submission status: Wrong Answer

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

print(n-len(s))

Submission status: Wrong Answer

Solution code:
import math
from collections import Counter
n,m=map(int,input().split())
e=[int(x) for x in input().split()]
di={}
for i in range(m):
	a,b=map(int,input().split())
	if a in di:
		di[a]+=[b]
	else: di[a]=[b]
	if b in di:
		di[a]+=[a]
	else: di[b]=[a]

c=0
for u,v in di.items():
	h=e[u-1]
	f=False
	for i in v:
		if h<=e[i-1]:
			f=True
			break
	if not f:
		c+=1
for i in range(1,len(e)+1):
	if i not in di:
		c+=1
print(c)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
Hi = list(map(int, input().split()))
is_judge_list = [1 for i in range(N)]

for j in range(M):
    A, B = map(int, input().split())
    if Hi[A-1] > Hi[B-1]:
       is_judge_list[B-1] = 0 
    elif Hi[B-1] > Hi[A-1]:
        is_judge_list[A-1] = 0
    else:
        is_judge_list[A-1] = 0
        is_judge_list[B-1] = 0
print(is_judge_list.count(0))

Submission status: Wrong Answer

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

N,M=(int(x) for x in input().rstrip('\n').split())
Hs = [int(x) for x in input().rstrip('\n').split()]
nums = set(Hs)
for i in range(M):
  roads = [int(x) for x in input().rstrip('\n').split()]
  eject = min(Hs[roads[0]-1],Hs[roads[1]-1])
  if eject in nums:
    nums.remove(eject)
print(len(nums))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    nm = list(map(int, input().split()))
    h = list(map(int, input().split()))
    ab = [None]*nm[1]
    for i in range(nm[1]):
        ab[i] = list(map(int, input().split()))

    memo = [0]*nm[0]
    for i in range(nm[1]):
        a = ab[i][0]-1
        b = ab[i][1]-1
        if h[a] > h[b]:
            memo[b] = 1
        elif h[a] < h[b]:
            memo[a] = 1
    
    print(memo.count(0))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

tmp=[0]*N

for li in S:
    A=li[0]-1
    B=li[1]-1

    if H[A]>=H[B]:
        tmp[B]=1
    elif H[A]<=H[B]:
        tmp[A]=1

c=tmp.count(0)
print(c)