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())
Hlist = list(map(int, input().split()))
goodSign = list(range(1,N+1))
routeList = []

for i in range(M):
  nowRoute = list(map(int, input().split()))
  if len(goodSign) == 0:
    print("0")
    exit()
  if nowRoute in routeList:
    if nowRoute[0] in goodSign:
      goodSign.remove(nowRoute[0])
    if nowRoute[1] in goodSign:
      goodSign.remove(nowRoute[1])
  else:
    if Hlist[nowRoute[0]-1] < Hlist[nowRoute[1]-1]:
      if nowRoute[0] in goodSign:
        goodSign.remove(nowRoute[0])
    else:
      if nowRoute[1] in goodSign:
        goodSign.remove(nowRoute[1])
    routeList.append(nowRoute)

print(len(goodSign))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
Hlist = list(map(int, input().split()))
goodSign = list(range(1,N+1))
routeList = []

for i in range(M):
  nowRoute = list(map(int, input().split()))
  if nowRoute in routeList:
    if nowRoute[0] in goodSign:
      goodSign.remove(nowRoute[0])
    if nowRoute[1] in goodSign:
      goodSign.remove(nowRoute[1])
  else:
    if Hlist[nowRoute[0]-1] < Hlist[nowRoute[1]-1]:
      if nowRoute[0] in goodSign:
        goodSign.remove(nowRoute[0])
    else:
      if nowRoute[1] in goodSign:
        goodSign.remove(nowRoute[1])
  routeList.append(nowRoute)

print(len(goodSign))

Submission status: Wrong Answer

Solution code:
N,M = map(int, input().split(' '))
heightList = input().split(' ')
checkifBestLT = [1 for i in range(N)]
# print(heightList)
# print(checkifBestLT)

for i in range(M):
    node = input().split(' ')
    if heightList[int(node[0])-1] > heightList[int(node[1])-1]:
        checkifBestLT[int(node[1])-1] = 0
    elif heightList[int(node[0])-1] < heightList[int(node[1])-1]:
        checkifBestLT[int(node[0])-1] = 0
    else:
        checkifBestLT[int(node[1])-1] = 0
        checkifBestLT[int(node[0])-1] = 0
print(sum(checkifBestLT))

Submission status: Wrong Answer

Solution code:
N, M = list(map(int,input().split()))
H = list(map(int,input().split()))
A = [None for _ in range(M)]
B = [None for _ in range(M)]
MAX = []
#リストに入れる時、int型だとsplit()が使えないっぽい
for i in range(M):
  A[i], B[i] = input().split()
for i in range(M):
  A[i] = int(A[i])
  B[i] = int(B[i])
for i in range(M):
  MAX.append(max(H[A[i]-1], H[B[i]-1]))
print(len(list(set(MAX))))

Submission status: Wrong Answer

Solution code:
def main():
    n,m = map(int, input().split())
    h = list(map(int, input().split()))
    ab = {}
    for _ in range(m):
        a,b = map(int, input().split())
        ab[a] = ab.get(a, set())
        ab[a].add(b)
        
        ab[b] = ab.get(b, set())
        ab[b].add(a)

    ans = set()
    for num, val in enumerate(h,1):
        if (tenbodai := ab.get(num, [])):
            for i in tenbodai :
                if val > h[i-1]:
                    ans.add(num)
        else:
            ans.add(num)
    print(len(ans))
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

from typing import Iterable


def main() -> None:
    N, M = rmi()
    H = rmi()
    A, B = [], []
    for m in range(M):
        a, b = rmi()
        A.append(a)
        B.append(b)
    cand = set(range(1, N + 1))
    for m in range(M):
        a, b = A[m], B[m]
        ha, hb = H[a - 1], H[b - 1]
        if ha == hb:
            continue
        lower = a if H[a - 1] < H[b - 1] else b
        if lower in cand:
            cand.remove(lower)
    w(len(cand))


def r() -> str:
    return input().strip()


def ri() -> int:
    return int(r())


def rmi(delim: str = ' ') -> int:
    return tuple(map(int, input().split(delim)))


def w(data) -> None:
    print(data)


def wm(data: Iterable) -> None:
    print(' '.join(data))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

from typing import Iterable


def main() -> None:
    N, M = rmi()
    H = rmi()
    A, B = [], []
    for m in range(M):
        a, b = rmi()
        A.append(a)
        B.append(b)
    cand = set(range(1, N + 1))
    for m in range(M):
        a, b = A[m], B[m]
        lower = a if H[a - 1] < H[b - 1] else b
        if lower in cand:
            cand.remove(lower)
    w(len(cand))


def r() -> str:
    return input().strip()


def ri() -> int:
    return int(r())


def rmi(delim: str = ' ') -> int:
    return tuple(map(int, input().split(delim)))


def w(data) -> None:
    print(data)


def wm(data: Iterable) -> None:
    print(' '.join(data))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ls = [[0]*m]*n

high = list(map(int, input().split()))
for i in range(m):
    tmp = list(map(int, input().split()))
    a = tmp[0]
    b = tmp[1]
    ls[a-1].append(b)

cnt = 0
for i in range(n):
    judge = 0
    q = 0
    while judge == 0 and q < m:
        if high[i] < ls[i][m]:
            judge = 1
        q += 1
    if judge == 0:
        cnt += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
# C
# Peaks

N, M = map(int, input().split())
H = [int(x) for x in input().split()]
N_list = list(range(1,N+1))
del_list = []
for i in range(M):
    A, B = map(int, input().split())
    if H[A-1] >= H[B-1]:
        del_list.append(A)
    if H[A-1] <= H[B-1]:
        del_list.append(B)

unique_list = set(del_list)
for i in unique_list:
    N_list.remove(i)

print(len(N_list))

Submission status: Wrong Answer

Solution code:
n, m = [int(x) for x in input().split()]
h = [int(x) for x in input().split()]
assert len(h) == n
h = [0] + h
bad = set()
for _ in range(m):
    a, b = [int(x) for x in input().split()]
    if h[a] < h[b]:
        bad |= {a}
    else:
        bad |= {b}
print(n - len(bad))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

workList = [1] * n

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

print(sum(workList))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split(" "))
height = list(map(int, input().split(" ")))
flag = [1 for i in height]
for i in range(M):
  a, b = map(int, input().split(" "))
  if height[a - 1] > height[b - 1]:
    flag[b - 1] = 0
  elif height[b - 1] > height[a - 1]:
    flag[a - 1] = 0
print(sum(flag))

Submission status: Wrong Answer

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

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


for p in range(N):
  for q in range(N):
    if X[p][q]==1:
      if H[p]>H[q]:
        count.append(p)
        
print(len(list(set(count))))

Submission status: Wrong Answer

Solution code:
def i():
    return int(input())
def i2():
    return map(int,input().split())
def s():
    return str(input())
def l():
    return list(input())
def intl():
    return list(int(k) for k in input().split())

n,m=i2()
h=intl()
cnt=0
score=0
l=[[] for i in range(n)]
for j in range(m):
	a,b=i2()
	l[a-1].append(b-1)
	l[b-1].append(a-1)
for j in range(n):
	for k in l[j]:
		if h[j]>k:
			cnt+=1
			if cnt==len(l[j]):
				score+=1
	cnt=0
print(score)

Submission status: Wrong Answer

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

highest_count = 0
for n in range(N):
    h = H[n]
    is_highest = True
    for load in load_list:
        if n+1 == load[0]:
            other = load[1]
            other_height = H[other-1]
            if h < other_height:
                is_highest = False
                break
        elif n+1 == load[1]:
            other = load[0]
            other_height = H[other-1]
            if h < other_height:
                is_highest = False
                break
    if is_highest:
        highest_count += 1

print(highest_count)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
H = input().split()
list_h = [int(n) for n in H]
list_a = []
list_b = []
MAX_A = []

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

for j in range(M):
    a = list_a[j]
    b = list_b[j]
    MAX = max(list_h[a-1], list_h[b-1])
    MAX_A.append(MAX)

MAX_A = set(MAX_A)
print(len(MAX_A))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
H = input().split()
list_h = [int(n) for n in H]
list_a = []
list_b = []
count = 0
MAX_A = []

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

for j in range(M):
    a = list_a[j]
    b = list_b[j]
    MAX = max(list_h[a-1], list_h[b-1])
    MAX_A.append(MAX)

MAX_A = set(MAX_A)
print(len(MAX_A))

'''
for j in range(M):
    if list_h[list_a[j]-1] > list_h[list_b[j]-1]:
        list_b[j] = 0
    elif list_h[list_a[j]-1] == list_h[list_b[j]-1]:
        list_b[j] = 0
    else:
        list_a[j] = 0

list_A = [i for i in list_a if i != 0]
list_B = [i for i in list_b if i != 0]

a = set(list_A)
b= set(list_B)

print(len(a) + len(b))
'''

Submission status: Wrong Answer

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

highest_count = 0
for n in range(N):
    h = H[n]
    is_highest = True
    for load in load_list:
        if n+1 == load[0] or n+1 == load[1]:
            other = load[1]
            other_height = H[other-1]
            if h < other_height:
                is_highest = False
                break
    if is_highest:
        highest_count += 1

print(highest_count)

Submission status: Wrong Answer

Solution code:
import itertools
n,m=map(int,input().split())
h=[int(i) for i in input().split()]
a=[str(j) for j in range(1,n+1)]
d=dict(zip(a,h))
r=[input().split() for k in range(m)]
lists=[]
for l in r:
    if d[l[0]]>d[l[1]]: 
        lists.append(l[0])
    elif d[l[0]]<d[l[1]]:
        lists.append(l[1])
e=[o for o in range(1,n+1)]
b=list(itertools.chain.from_iterable(r))
f=list(set(b))
g=[int(p) for p in f]
for q in e:
    s=q in g
    if s==False:
        lists.append(q)
print(len(set(lists)))

Submission status: Wrong Answer

Solution code:
import itertools
n,m=map(int,input().split())
h=[int(i) for i in input().split()]
a=[str(j) for j in range(1,n+1)]
d=dict(zip(a,h))
r=[input().split() for k in range(m)]
lists=[]
for l in r:
    if d[l[0]]>d[l[1]]: 
        lists.append(l[0])
    elif d[l[0]]<d[l[1]]:
        lists.append(l[1])
e=[o for o in range(1,n+1)]
b=list(itertools.chain.from_iterable(r))
f=list(set(b))
g=[int(p) for p in f]
c=sum(e)-sum(g)
if c!=0:
    lists.append(c)
print(len(set(lists)))

Submission status: Wrong Answer

Solution code:
import itertools
n,m=map(int,input().split())
h=[int(i) for i in input().split()]
a=[str(j) for j in range(1,n+1)]
d=dict(zip(a,h))
r=[input().split() for k in range(m)]
lists=[]
for l in r:
    if d[l[0]]>d[l[1]]: 
        lists.append(d[l[0]])
    elif d[l[0]]<d[l[1]]:
        lists.append(d[l[1]])
e=[o for o in range(1,n+1)]
b=list(itertools.chain.from_iterable(r))
f=list(set(b))
g=[int(p) for p in f]
c=sum(e)-sum(g)
if c!=0:
    lists.append(c)
print(len(set(lists)))

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
H = list(map(int,input().split()))
P = [0] * N
print(H,P)
for i in range(M) :
    q = list(map(int,input().split()))
    p = P[q[0]-1]
    h = H[q[1]-1]
    if p < h :
        P[q[0]-1] = H[q[1]-1]
    if p > h :
        P[q[1]-1] = H[q[0]-1]

R = 0
for i in range(N) :
    if H[i] > P[i] :
        R += 1
print(R)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
H=list(map(int,input().split()))
ans=[0]*N    #N個のメモ欄を用意
for i in range(M):
    A,B=map(int,input().split())
    if H[A-1]<H[B-1]:    #A,Bで繋がれた展望台のうち、低いほうに印を着けていく。
        ans[A-1]+=1
    elif H[B-1]<H[A-1]:
        ans[A-1]+=1
    else:    #AとBの標高が同じならどちらにも印をつける。
        ans[A-1]+=1
        ans[B-1]+=1
print(ans.count(0))    #印をつけられていない展望台をカウント。

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
H=list(map(int,input().split()))
ans=[0]*N    #N個のメモ欄を用意
for i in range(M):
    A,B=map(int,input().split())
    if H[A-1]<H[B-1]:    #A,Bで繋がれた展望台のうち、低いほうに印を着けていく。
        ans[A-1]=1
    elif H[B-1]<H[A-1]:
        ans[A-1]=1
    else:    #AとBの標高が同じならどちらにも印をつける。
        ans[A-1]=1
        ans[B-1]=1
print(ans.count(0))    #印をつけられていない展望台をカウント。

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
h = {}
v = []
for i in input().split():
  h[int(i)] = []
  v.append(int(i))

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

ans = 0

for key, value in h.items():
  if len(value) == 0:
    ans += 1
    continue

  if key >= max(value):
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
h = {}
v = []
for i in input().split():
  h[int(i)] = []
  v.append(int(i))

for i in range(m):
  a, b = map(int, input().split())
  h[v[a-1]].append(v[b-1])
  h[v[b-1]].append(v[a-1])
  
ans = 0

for key, value in h.items():
  if len(value) == 0:
    ans += 1
    continue

  if key > max(value):
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
def l(): return [int(a) for a in input().split(" ")] 
ka = l()
lis = {}
saku = []
for i,a in zip(range(ka[0]),l()):
  lis[i+1] = a
for _ in range(ka[1]):
  q = l()
  maxindex = []
  a = [[lis[a],a] for a in q if a in lis]
  maxv = max(a)
  for b in a:
    if maxv[0] == b[0]:
      maxindex.append(b)
  q.pop(q.index(maxv[1]))
  for m in maxindex:
  	q.append(m[1])
  for a in q:
    saku.append(a)
print(len([a for a in lis if a not in saku]))

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=[1 for i in range(n)]

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

print(sum(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 i in range(m)]

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

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

print(sum(ans))

Submission status: Wrong Answer

Solution code:
def q3():
    N, M = (int(i) for i in input().split())
    H = [int(i) for i in input().split()]
    ans = [True]*N

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

        if H[A-1] <= H[B-1]:
            ans[A-1] = False
        if H[B-1] <= H[A-1]:
            ans[B-1] = False

    print(ans)


if __name__ == '__main__':
    q3()

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)]
ab.sort()
cnt = 0

for j in range(len(ab)-1):
    if ab[j] == ab[j+1]:
        cnt += 1


jud = [True]*n

for i in ab:
    if h[i[0] - 1] > h[i[1] - 1]:
        jud[i[1] - 1] = False
    if h[i[0] - 1] < h[i[1] - 1]:
        jud[i[0] - 1] = False

print(jud.count(True) - cnt)

Submission status: Wrong Answer

Solution code:
n,m = list(map(int,input().split()))
h = list(map(int,input().split()))
e = [[] for _ in range(n)]
c = [[] for _ in range(n)]
for i in range(m):
    a,b = list(map(int,input().split()))
    a -= 1
    b -= 1
    e[a].append(b)
    e[b].append(a)
ans = 0
for i in range(n):
    f = h[i]
    for j in range(len(e[i])):
        t = h[e[i][j]]
        if h[i] == t:
            t += 1
        f = max([h[i],t])
    if f == h[i]:
        ans += 1
print(ans)

Submission status: Wrong Answer

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

    for j in range(len([e[i]])):
        if e[i] == []:
            continue
        t = h[e[i][j]]
        if h[i] == t:
            t += 1
        f = max([h[i],t])
    if f == h[i]:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
count, way = list(map(int, input().split()))
height = list(map(int, input().split()))
isGood = [True] * count

for i in range(way):
    obs_a, obs_b = list(map(lambda x: int(x) - 1, input().split()))
    if(height[obs_a] > height[obs_b]):
        isGood[obs_b] = False
    else:
        isGood[obs_a] = False


print(len([ i for i in isGood if i ]))

Submission status: Wrong Answer

Solution code:
count, way = list(map(int, input().split()))
height = list(map(int, input().split()))
isGood = [True] * count

for i in range(way):
    obs_a, obs_b = list(map(lambda x: int(x) - 1, input().split()))
    if(height[obs_a] > height[obs_b]):
        isGood[obs_b] = False
    else:
        isGood[obs_a] = False

print(isGood)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
H = list(map(int,input().split()))
W = [1 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]:
        W[b] = 0
    elif H[b] >= H[a]:
        W[a] = 0
ans = 0
for i in W:
    ans += i
print(ans)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
H = list(map(int,input().split()))
W = {i:0 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]:
        W[b] = 1
    elif H[b] >= H[a]:
        W[a] = 1
ans = 0
for i in W.keys():
    if W[i] == 0:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
height = list(map(int,input().split()))
lst = [0]*n
for j in range(m):
    x,y = map(int,input().split())
if height[x-1] >= height[y-1]:
    lst[y-1] = 1
if height[x-1] <= height[y-1]:
    lst[x-1] = 1
print(lst.count(0))

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
height = list(map(int,input().split()))
lst = [0]*n
for j in range(m):
    x,y = map(int,input().split())
if height[x-1] >= height[y-1]:
    lst[y-1] = 1
if height[x-1] <= height[y-1]:
    lst[x-1] = 1
    print(lst.count(0))

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
height = list(map(int,input().split()))
lst = [0]*n
for j in range(m):
    x,y = map(int,input().split())
if height[x-1] >= height[y-1]:
    lst[x-1] = 1
if height[x-1] <= height[y-1]:
    lst[y-1] = 1
    print(lst.count(0))

Submission status: Wrong Answer

Solution code:
import sys
import math

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

Submission status: Wrong Answer

Solution code:
import sys
import math

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

Submission status: Wrong Answer

Solution code:
import sys
import math

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

Submission status: Wrong Answer

Solution code:
import sys
import math

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

Submission status: Wrong Answer

Solution code:
import sys
import math

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

Submission status: Wrong Answer

Solution code:
import sys
import math

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

Submission status: Wrong Answer

Solution code:
# データ入力
N,M = map(int,input().split())
H = [int(i) for i in input().split()]

# 山のインデックスリスト
good = {i for i in range(1,N+1)}

for m in range(M):
    # 山の経路の入力
    a,b = [int(i) for i in input().split()]
    if H[a-1]>=H[b-1]:
        good = good - {b}
    elif H[a-1]<=H[b-1]:
        good = good - {a}

print(len(good))

Submission status: Wrong Answer

Solution code:
import sys
import math

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,M = map(int, input().split())
hight_list = list(map(int, input().split()))
result_list = [True] * N

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

print(result_list.count(True))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import math
n, m = map(int, input().split())
h=list(map(int,input().split()))
bli = h
for i in range(m):
    a, b = map(int, input().split())
    bli[a - 1] = max(bli[a - 1], b)
cnt=0
for i in range(n):
    if (h[i] == bli[i]):
        cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
import sys
import math
n, m = map(int, input().split())
h=list(map(int,input().split()))
bli = h
for i in range(m):
    a, b = map(int, input().split())
    bli[a - 1] = max(bli[a - 1], b)
cnt=0
for i in range(n):
    if (h[i] == bli[i]):
        cnt += 1
print(cnt//2)

Submission status: Wrong Answer

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

ans = 0
a = []
b = []

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

for i in range(n):
    h_i = [0]
    if i + 1 in a:
        h_i.append(h[b[a.index(i + 1)] - 1])
    if i + 1 in b:
        h_i.append(h[a[b.index(i + 1)] - 1])
    if h[i] > max(h_i):
        ans += 1

print(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,b=map(int,input().split())
    A[i]+=a
    B[i]+=b
C=list(A)
for i in range(m):
    if H[A[i]-1]>H[B[i]-1]:
        C[i],B[i]=B[i],A[i]
    if H[A[i]-1]==H[B[i]-1]:
        C.append(B[i])
S=n
for i in range(1,n+1):
    if i in C:
        S-=1
print(S)

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect

def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    n, m = LI()
    h = LI()
    li = LIR(m)
    flag_list = [False] * n
    for i in range(m):
        if h[li[i][1]-1] > h[li[i][1]-1]:
            flag_list[li[i][1]-1] = True
        elif h[li[i][0]-1] < h[li[i][1]-1]:
            flag_list[li[i][0]-1] = True
        else:
            flag_list[li[i][1]-1] = True 
            flag_list[li[i][1]-1] = True
    print(flag_list.count(False))

    return


if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
import sys

def LI(): return map(int, sys.stdin.readline().rstrip().split())

N, M = LI()

H = [*LI()]
connections = [[*LI()] for _ in range(M)]

good_observatories = 0
for idx, h in enumerate(H):
    good_flag = True
    for c in connections:
        if idx == c[0] - 1:
            good_flag = h > H[c[1] - 1]
        elif idx == c[1] - 1:
            good_flag = h > H[c[0] - 1]
    if good_flag: good_observatories += 1
print(good_observatories)

Submission status: Wrong Answer

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

road = {}
for i, h in zip(range(1, N + 1, 1), H):
    road[i] = {
        "high": h,
        "connect": [],
        "good": True
    }

for i in range(M):
    Ai, Bi = map(int, input().split())
    
    road[Ai]["connect"] = list(set(road[Ai]["connect"] + [Bi]))
    if road[Ai]["high"] < road[Bi]["high"]:
        road[Ai]["good"] = False
    
    road[Bi]["connect"] = list(set(road[Bi]["connect"] + [Ai]))
    if road[Bi]["high"] < road[Ai]["high"]:
        road[Bi]["good"] = False
        
print(len([1 for i in range(1, N + 1, 1) if road[i]["good"] is True]))

Submission status: Wrong Answer

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

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[A-1] < H[B-1]:
        C[A-1]=1
        
    if H[A-1] == H[B-1]:
        if C[A-1]==1:
            C[B-1] = 1
        if C[B-1]==1:
            C[A-1] = 1


print("{}".format(N-sum(C)))

Submission status: Wrong Answer

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

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
        H[B-1]=H[A-1]
    if H[A-1] < H[B-1]:
        C[A-1]=1
        H[A-1]=H[B-1]
    if H[A-1] == H[B-1]:
        if C[A-1]==1:
            C[B-1] = 1
        if C[B-1]==1:
            C[A-1] = 1


print("{}".format(N-sum(C)))

Submission status: Wrong Answer

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

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
        H[B-1]=H[A-1]
    if H[A-1] < H[B-1]:
        C[A-1]=1
        H[A-1]=H[B-1]
    if H[A-1] == H[B-1]:
        if H[A-1]==1:
            C[B-1] = 1
        if H[B-1]==1:
            C[A-1] = 1


print("{}".format(N-sum(C)))

Submission status: Wrong Answer

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

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[A-1] < H[B-1]:
        C[A-1]=1
    if H[A-1] == H[B-1]:
        if H[A-1]==1:
            C[B-1] = 1
        if H[B-1]==1:
            C[A-1] = 1


print("{}".format(N-sum(C)))