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: Accepted

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

T = [-1 for _ in range(N + 1)]

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

    T[a] = max(T[a], H[b])
    T[b] = max(T[b], H[a])

cnt = 0

for i in range(1, N + 1):
    if H[i] > T[i]:
        cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
n = [int(e) for e in input().split(" ")]
d = []
c = 0
for e in input().split(" "):
    d.append([(int(e)), []])
for _ in range(n[1]):
    x = [int(e) - 1 for e in input().split(" ")]
    d[x[0]][1].append(d[x[1]][0])
    d[x[1]][1].append(d[x[0]][0])
for e_d in d:
    try:
        m = max(e_d[1])
    except:
        m = -1
    if(m < e_d[0]):
        c += 1
print(c)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
Hi = list(map(int,input().split(" ")))
#path = [list() for _ in range(M+1)]

Tallest = [0]*N

for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    Tallest[a] = max(Tallest[a], Hi[b])
    Tallest[b] = max(Tallest[b], Hi[a])

goodT = 0

for i in range(N):
    if Hi[i]>Tallest[i]:
        goodT +=1
    
print (goodT)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
heights = list(map(int, input().split()))
 
greatest = [0] * N
for m in range(0, M):
  A, B = [int(s)-1 for s in input().split()]
  greatest[A] = max(greatest[A], heights[B])
  greatest[B] = max(greatest[B], heights[A])
    
count = 0
for i in range(0, N):
    count += heights[i] > greatest[i]
    
print(count)

Submission status: Accepted

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

def main():
    N, M = map(int, input().split())
    V = [True] * N
    H = [int(v) for v in input().split()]
    AB = [[int(v) - 1 for v in input().split()] for _ in range(M)]
    for a, b in AB:
        if V[a] or V[b]:
            if H[a] <= H[b]:
                V[a] = False
            if H[a] >= H[b]:
                V[b] = False
    
    print(V.count(True))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

def main():
    N, M = map(int, input().split())
    V = [True] * N
    H = [int(v) for v in input().split()]
    AB = [[int(v) - 1 for v in input().split()] for _ in range(M)]
    for a, b in AB:
        # if V[a] or V[b]:
        if H[a] <= H[b]:
            V[a] = False
        if H[a] >= H[b]:
            V[b] = False
    
    print(V.count(True))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

    if H[A] == H[B]:
        good[A] = good[B] = False
    else:
        good[B if H[A] - H[B] > 0 else A] = False

print([x for x in good if x].__len__())

Submission status: Accepted

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

goodObservatory = [1]*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]:
		goodObservatory[B-1] = 0
	elif H[A-1] < H[B-1]:
		goodObservatory[A-1] = 0
	elif H[A-1] == H[B-1]:
		goodObservatory[A-1] = 0
		goodObservatory[B-1] = 0

print(sum(goodObservatory))

Submission status: Accepted

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

AB = []
for i in range(M):
    A,B = map(int,input().split())
    AB.append([A,B])
h = [0]
for i in range(N):
    h.append(1)
    
for k in range (M):
    i = AB[k][0]
    j = AB[k][1]
    if H[i] < H[j]:
        h[i] = 0
    elif H[i] > H[j]:
        h[j] = 0
    else:
        h[i] = 0
        h[j] = 0

print(sum(h))

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
H = [0]
h = list(map(int,input().split()))
H += h 
AB = []
for i in range(M):
    A,B = map(int,input().split())
    AB.append([A,B])
h = [0]
for i in range(N):
    h.append(1)
    
for k in range (M):
    i = AB[k][0]
    j = AB[k][1]
    if H[i] < H[j]:
        h[i] = 0
    elif H[i] > H[j]:
        h[j] = 0
    else:
        h[i] = 0
        h[j] = 0

print(sum(h))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
h = list(map(int, input().split()))
view = [True] * n
for j in range(m):
    a, b = map(int, input().split())
    a -=1
    b -=1
    if h[a] < h[b]:
        view[a] = False
    elif h[a] > h[b]:
        view[b] = False
    elif h[a] == h[b]:
        view[a] = False
        view[b] = False

print(view.count(True))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
class Graph(): #non-directed
    def __init__(self,n,edge):
        self.n = n
        self.graph = [[] for _ in range(n)]
        self.deg = [0 for _ in range(n)]
        for e in edge:
            self.graph[e[0]-1].append(e[1]-1)
            self.graph[e[1]-1].append(e[0]-1)
            self.deg[e[0]-1] += 1
            self.deg[e[1]-1] += 1

import sys
input = sys.stdin.readline

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

E = [tuple(map(int, input().split())) for _ in range(M)]

G = Graph(N, E)

res = 0

for node in range(N):
    flag = True
    for adj in G.graph[node]:
        if H[adj] >= H[node]:
            flag = False
            break
    res += flag

print(res)

Submission status: Accepted

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


Flags = [1] * N

for j in range(M):
    if(H[AB[j][0] - 1] <= H[AB[j][1] - 1]):
        Flags[AB[j][0] - 1] = 0

    if(H[AB[j][1] - 1] <= H[AB[j][0] - 1]):
        Flags[AB[j][1] - 1] = 0

count = 0
for i in range(N):
    count += Flags[i]



print(count)

Submission status: Accepted

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

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

good = [True] * N

for _ in range(M):
  A, B = map(int, input().split())
  A -= 1
  B -= 1
  if H[A] >= H[B]:
    good[B] = False
  if H[A] <= H[B]:
    good[A] = False
print(sum(good))

Submission status: Accepted

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

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

better = [[] for _ in H]

for _ in range(M):
  A, B = map(int, input().split())
  A -= 1
  B -= 1
  if H[A] >= H[B]:
    better[B].append(A)
  if H[A] <= H[B]:
    better[A].append(B)
print(sum([1 for b in better if not b]))

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
H=list(map(int,input().split()))
t=[1]*N
for i in range(M):
    a,b=map(int,input().split())
    if H[a-1]>H[b-1]:
        t[b-1]=0
    elif H[a-1]<H[b-1]:
        t[a-1]=0
    else:
        t[a-1],t[b-1]=0,0
print(sum(t))

Submission status: Accepted

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

ans = [1] * N

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

Submission status: Accepted

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

Submission status: Accepted

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


high = list(map(int, input().split()))
good = [0 for i in range(N)]



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

        
print(good.count(0))

Submission status: Accepted

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

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

count=0
for i in range(N):
    if not connect[i]:
        count+=1
    elif H[i]>max(connect[i]):
        count+=1
# for i in range(N):
#     print(connect[i])
print(count)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
H = [int(x) for x in input().split()]

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

ans = 0
for i in range(N):
    is_ok = True
    for adj in Graph[i]:
        if H[i] <= H[adj]:
            is_ok = False
    if is_ok:
        ans += 1

print(ans)

Submission status: Accepted

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

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

is_good = [True]*n

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

cnt = 0
for i in is_good:
  if i == True:
    cnt += 1

print(cnt)

Submission status: Accepted

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

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

Submission status: Accepted

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

s=set()
for _ in range(m):
    a, b = map(int, input().split())
    a_h=h[a-1]
    b_h=h[b-1]
    if a_h>=b_h:
        s.add(b)
    if a_h<=b_h:
        s.add(a)

ans = n-len(s)
print(ans)

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,m = LI()
    h = LI()
    ab = [LI_() for _ in range(m)]
    r = [1] * n
    for a,b in ab:
        if h[a] <= h[b]:
            r[a] = 0
        if h[b] <= h[a]:
            r[b] = 0

    return sum(r)


print(main())

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
h = [int(x) for x in input().split()]
bad = set()
for i in range(m):
    a, b = map(int, input().split())
    if h[a-1] > h[b-1]:
        bad.add(b)
    elif h[a-1] == h[b-1]:
        bad.add(a)
        bad.add(b)
    elif h[a-1] < h[b-1]:
        bad.add(a)
print(n - len(bad))

Submission status: Accepted

Solution code:
from sys import stdin
import numpy as np


def main():
    n, m = list(map(int, stdin.readline().split()))
    hList = list(map(int, stdin.readline().split()))
    ABList = [list(map(int, stdin.readline().split())) for _ in range(m)]
    maxHeights = np.zeros(n)
    for a, b in ABList:
        if hList[a-1] >= maxHeights[b-1]:
            maxHeights[b-1] = hList[a-1]
        if hList[b-1] >= maxHeights[a-1]:
            maxHeights[a-1] = hList[b-1]
    total = 0
    i = 0
    for maxHeight in maxHeights:
        if maxHeight < hList[i]:
            total += 1
        i += 1
    print(total)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

cnt = 0
for i in range(n):
    H = h[i]
    max1 = 0
    for j in d[i]:
        max1 = max(max1,h[j])
    if H > max1:
        cnt +=1        
print(cnt)

Submission status: Accepted

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

tall=[1]*n

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


print(sum(tall))

Submission status: Accepted

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

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

good_H = [1] * N

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

print(good_H.count(1))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict

N ,M = map(int,input().split())
H = list(map(int,input().split()))
graph = defaultdict(int)
for _ in range(M):
    A, B = map(int,input().split())
    graph[A]= max(graph[A],H[B-1])
    graph[B]= max(graph[B],H[A-1])

print(sum(H[i-1] > graph[i] for i in range(1,N+1)))

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
H=[int(h) for h in input().split()]
MAX=[-1 for _ in range(N)]
for _ in range(M):
    A,B=map(int,input().split())
    MAX[A-1]=max(H[B-1],MAX[A-1])
    MAX[B-1]=max(H[A-1],MAX[B-1])

ans=sum(int(h>M) for h,M in zip(H,MAX))
print(ans)

Submission status: Accepted

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

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

ans = 0
for i in range(n):
    mx = 0
    for j in G[i]:
        mx = max(mx, h[j])
    if mx < h[i]:
        ans += 1

print(ans)

Submission status: Accepted

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

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

print(sum(highest))

Submission status: Accepted

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())
list = []
for i in range(M):
  if H[A[i]-1]>=H[B[i]-1]:
    list.append(B[i])
  if H[A[i]-1]<=H[B[i]-1]:
    list.append(A[i])
#print("N:{} M:{} H:{} list:{} set(list):{}".format(N,M,H,list,set(list)))
print(N-len(set(list)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
H = [-1] + list(map(int ,input().split()))
is_good = [1] * (N+1)
is_good[0] = 0
for _ in range(M):
    a,b = map(int, input().split())
    ha,hb = H[a], H[b]
    if ha > hb:
        is_good[b] = 0
    if hb > ha:
        is_good[a] = 0
    if ha == hb:
        is_good[a] = 0
        is_good[b] = 0

print(sum(is_good))

Submission status: Accepted

Solution code:


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N, M = read_ints()
    H = read_ints()
    is_good = [True]*N
    for _ in range(M):
        a, b = read_ints()
        a -= 1
        b -= 1
        if H[a] >= H[b]:
            is_good[b] = False
        if H[a] <= H[b]:
            is_good[a] = False
    return is_good.count(True)


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

Submission status: Accepted

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

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

ans = 0
for i in range(N):
    if ma[i] < h[i]:
        ans += 1

print(ans)

Submission status: Accepted

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

if __name__ == "__main__":
  run()

Submission status: Accepted

Solution code:
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations,combinations,combinations_with_replacement
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
N,M = map(int,input().split())
lisH = [0] + list(map(int,input().split()))
lisAB = lisH.copy()
for i in range(M):
    A,B = map(int,input().split())
    if lisH[A] > lisH[B]:
        lisAB[B] = 0
    elif lisH[A] < lisH[B]:
        lisAB[A] = 0
    else:
        lisAB[A] = 0
        lisAB[B] = 0
        
ans = 0
for i in range(1,N+1):
    if lisH[i] == lisAB[i]:
        ans += 1

print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))

Submission status: Accepted

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

Submission status: Accepted

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

maxh = [0]*n
for a, b in ab:
  maxh[a-1] = max(maxh[a-1], hlist[b-1])
  maxh[b-1] = max(maxh[b-1], hlist[a-1])
ans = 0
for i in range(n):
  if maxh[i] < hlist[i]:
    ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

isGood = [True] * n

for i in range(m):
    a, b = map(int, input().split())
    if heights[a-1] > heights[b-1] :
        isGood[b-1] = False
    elif heights[b-1] > heights[a-1] :  
        isGood[a-1] = False
    else :  
        isGood[a-1] = False
        isGood[b-1] = False
    
print (isGood.count(True))

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
H = list(map(int,input().split()))
L = [0] * N
for _ in range(M):
    a,b = map(int,input().split())
    if H[a-1] > H[b-1]:
        L[b-1] += 1
    elif H[a-1] < H[b-1]:
        L[a-1] += 1
    else:
        L[a-1] += 1
        L[b-1] += 1
ans = L.count(0)
print(ans)

Submission status: Accepted

Solution code:
ii = lambda:int(input())
mi = lambda:list(map(int,input().split()))
ix = lambda x:list(input() for _ in range(x))
mix = lambda x:list(mi() for _ in range(x))
iix = lambda x:list(int(input()) for _ in range(x))
##########
def main(n,m,h,l):
    res = []
    g = {i:[] for i in range(1,n+1)}
    for a,b in l:
        g[a].append(b)
        g[b].append(a)
    for i in range(1,n+1):
        if len(g[i]) == 0:
            res.append(i)
            continue
        maxheight = 0
        for p in g[i]:
            maxheight = max(maxheight, h[p-1])
        if h[i-1] > maxheight:
            res.append(i)
    return len(res)

n,m = mi()
h = mi()
l = mix(m)
print(main(n,m,h,l))

Submission status: Accepted

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

Submission status: Accepted

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

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

A = [0] * n
for i in range(m):
    a, b = map(int, input().split())
    if L[a - 1] == L[b - 1]:
        A[b - 1] = 1
        A[a - 1] = 1
    elif L[a-1] > L[b-1]:
        A[b - 1] = 1
    else:
        A[a - 1] = 1
print(A.count(0))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

def solve(N: int, M: int, H: "List[int]", A: "List[int]", B: "List[int]"):
    not_good = set()
    for i in range(M):
        if H[A[i] - 1] < H[B[i] - 1]:
            not_good.add(A[i])
        elif H[B[i] - 1] < H[A[i] - 1]:
            not_good.add(B[i])
        else:
            not_good.add(A[i])
            not_good.add(B[i])
    good = set(range(1, N + 1)) - not_good
    print(len(good))
    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))
        B[i] = int(next(tokens))
    solve(N, M, H, A, B)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

d = [True for i in range(n)] 

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

print(d.count(True))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

tmp = [1] * n

ab = [map(int, input().split()) for _ in range(m)]
a, b = [list(i) for i in zip(*ab)]

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

print(sum(tmp))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
H = [int(i) for i in input().split()]
ans = [True]*n
for  i in range(m):
    a, b = map(int, input().split())
    if H[a-1] < H[b-1]:
        ans[a-1] = False
    elif H[a-1] > H[b-1]:
        ans[b-1] = False
    elif H[a-1] == H[b-1]:
        ans[a-1] = False
        ans[b-1] = False
print(ans.count(True))

Submission status: Accepted

Solution code:
from collections import defaultdict

def main():
    N,M = [int(x) for x in input().split()]
    Hl = [int(x) for x in input().split()]
    Al,Bl = [],[]
    for i in range(M):
        A,B = [int(x) for x in input().split()]
        Al.append(A)
        Bl.append(B)

    is_peek = [1]*N
    m = defaultdict(list)
    for A,B in zip(Al,Bl):
        if Hl[A-1] > Hl[B-1]:
            is_peek[B-1] = 0
        elif Hl[A-1] == Hl[B-1]:
            is_peek[A-1] = 0
            is_peek[B-1] = 0
        else:
            is_peek[A-1] = 0
    print(sum(is_peek))
        

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, m = map(int,input().split())
H = [int(i) for i in input().split()]
ans = [True]*n
for i in range(m):
  a, b = map(int, input().split())
  if H[a-1] < H[b-1]:
    ans[a-1] = False
  elif H[a-1] > H[b-1]:
    ans[b-1] = False
  elif H[a-1] == H[b-1]:
    ans[a-1] = False
    ans[b-1] = False
print(ans.count(True))

Submission status: Accepted

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())
    ma = H[A-1]
    mb = H[B-1]
    if (ma > mb):
        L[B-1] = 0
    elif (ma == mb):
        L[B-1] = 0
        L[A-1] = 0
    else:
        L[A-1] = 0
print(sum(L))

Submission status: Accepted

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())))
    
ll=[0]*N

for j in l:
    if H[j[0]-1]-H[j[1]-1]>0:
        ll[j[1]-1]+=1
    elif H[j[0]-1]-H[j[1]-1]<0:    
        ll[j[0]-1]+=1
    else:
        ll[j[0]-1]+=1
        ll[j[1]-1]+=1
ans=0
for x in ll:
    if x==0:
        ans+=1

print(ans)

Submission status: Accepted

Solution code:
import numpy as np
 
n,m = input().split(" ")
n = int(n)
m = int(m)
 
H = input().split(" ")
H = np.array([int(h) for h in H])
Hs = np.zeros(n)

for i in range(m):
    a, b = input().split(" ")
    a = int(a) - 1
    b = int(b) - 1
    Hs[a] = np.max([Hs[a], H[b]])
    Hs[b] = np.max([Hs[b], H[a]])
 
G = []
for i in range(n):
    if Hs[i] < H[i]:
        G += [i]
 
print(len(G))

Submission status: Accepted

Solution code:
N,M = (int(x) for x in input().split())
hight = [int(x) for x in input().split()]
tenbou = [input().split() for l in range(M)]
result = [1] * N


for i in range(M):
    x = int(tenbou[i][0]) - 1
    y = int(tenbou[i][1]) - 1
    if hight[x] > hight[y]:
        result[y] = 0
    elif hight[y] == hight[x]:
        result[x] = 0
        result[y] = 0
    elif hight[y] > hight[x]:
        result[x] = 0
#print(result)
print(result.count(1))