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:
input1 = input().rstrip().split(" ")
h = input().rstrip().split(" ")
yoi = [1 for i in range(int(input1[0]))]
# h = [input().rstrip().split(" ") for i in range(int(input1[0]))]
# print(h)map(int, input().split())
root =  [input().rstrip().split(" ") for i in range(int(input1[1]))]

# root =  [input_lines.split(" ") for i in range(int(input1[1]))]
# print(int(root[0][0]))
for i in range(int(input1[1])):
    a=int(root[i][0])-1
    b=int(root[i][1])-1
    if h[a]> h[b]:
        # if  yoi[a] == 0:
        # yoi[a] = 1
        yoi[b] = -1
    elif h[a] < h[b]:
        # if  yoi[a] == 0:
        # yoi[a] = 1
        yoi[a] = -1
    else:
        # if  yoi[b] == 0:
            # yoi[b] = 1
        yoi[a] = -1
        yoi[b] = -1
print (yoi.count(1))

Submission status: Wrong Answer

Solution code:
input1 = input().rstrip().split(" ")
h = input().rstrip().split(" ")
yoi = [1 for i in range(int(input1[0]))]
# h = [input().rstrip().split(" ") for i in range(int(input1[0]))]
# print(h)map(int, input().split())
root =  [input().rstrip().split(" ") for i in range(int(input1[1]))]

# root =  [input_lines.split(" ") for i in range(int(input1[1]))]
# print(int(root[0][0]))
for i in range(int(input1[1])):
    a=int(root[i][0])-1
    b=int(root[i][1])-1
    if h[a]> h[b]:
        # if  yoi[a] == 0:
        # yoi[a] = 1
        yoi[b] = -1
    elif h[a] < h[b]:
        # if  yoi[a] == 0:
        # yoi[a] = 1
        yoi[a] = -1
    else:
        # if  yoi[b] == 0:
            # yoi[b] = 1
        yoi[b] = -1
print (yoi.count(1))

Submission status: Wrong Answer

Solution code:
input1 = input().rstrip().split(" ")
h = input().rstrip().split(" ")
yoi = [0 for i in range(int(input1[0]))]
root =  [input().rstrip().split(" ") for i in range(int(input1[1]))]
for i in range(int(input1[1])):
    a=int(root[i][0])-1
    b=int(root[i][1])-1
    if h[a]> h[b]:
        if  yoi[a] == 0:
            yoi[a] = 1
        yoi[b] = -1
    else:
        if  yoi[b] == 0:
            yoi[b] = 1
        yoi[a] = -1
print (yoi.count(1))

Submission status: Wrong Answer

Solution code:
#n,m = (6,5) # n個の展望台 m個の道
#h = [8,6,9,1,2,1]
#load = [[1,3],[4,2],[4,3],[4,6],[4,6]]

load = list()
n,m = map(int,input().split())
h = list(map(int,input().split()))
for i in range(m):
  x = list(map(int,input().split()))
  load.append(x)

good = [1] * n
for i in range(m):
  load[i][0] -= 1
  load[i][1] -= 1

for i in range(n):
  for j,data in enumerate(load):
    j1 = data[0]
    j2 = data[1]
    #print(j1,j2)
    if(j1 == i):
      #print(" ",h[i],h[j2]) #自分の高さ、相手の高さ
      if(h[i] <= h[j2]):
        good[i] = 0
        del load[j]
        break
    elif(j2 == i):
      #print(" ",h[i],h[j1]) #自分の高さ、相手の高さ
      if(h[i] <= h[j1]):
        good[i] = 0
        del load[j]
        break

print(sum(good))

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[a-1] = 0
    elif H[b-1]>H[a-1]:
        ans[b-1] = 0
    else:
        ans[a-1], ans[b-1] = 0, 0
print(sum(ans))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
arr = [0] + list(map(int,input().split()))
#A-Bがつながっている
g = [[] for _ in range(N+1)]
for _ in range(M):
    A, B = map(int,input().split())
    g[A].append(B)
    g[B].append(A)
ans = 0
for v in range(1,N+1):
    for u in g[v]:
        if arr[u]>=arr[v]:
            break
        else:
            ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
arr = [0] + list(map(int,input().split()))
#A-Bがつながっている
g = [[] for _ in range(N+1)]
print(arr)
print (g)
for _ in range(M):
    A, B = map(int,input().split())
    g[A].append(B)
    g[B].append(A)
print (g)
ans = 0
for v in range(1,N+1):
    for u in g[v]:
        if arr[u]>=arr[v]:
            break
        else:
            ans+=1
print(ans)

Submission status: Wrong Answer

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(x[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: Wrong Answer

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
        elif H[a] > H[b]:
            V[b] = False
    
    print(V.count(True))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
li = list(map(int,input().split()))
#A-Bがつながっている
set_all = set()
set_connect = set()
for i in range(1,M+1,1):
    A, B = map(int,input().split())
    set_connect.add(A)
    set_connect.add(B)
    A_tall = li[A-1]
    B_tall = li[B-1]
    if A_tall > B_tall:
        #Aが良い展望台
        set_all.add(A)
    elif A_tall < B_tall:
        #Bが良い展望台
        set_all.add(B)
    elif A_tall == B_tall:
        #AとBの高さが同じ
        #→AもBも良い展望台ではない
        pass
set_no_connect = {i for i in range(1,N,1)} - set_connect
set_res = set_all | set_no_connect
print(len(set_res))

Submission status: Wrong Answer

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

goodObservatory = [1]*N

H = 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: Wrong Answer

Solution code:
N, M = map(int, input().split())
heights = list(map(int, input().split()))
 
good = [True] * N
for m in range(0, M):
  A, B = [int(s)-1 for s in input().split()]
  if heights[A] >= heights[B]:
    good[B] = False
  elif heights[A] <= heights[B]:
    good[A] = False
    
count = 0
for obs in good:
  if obs: count += 1
    
print(count)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
heights = list(map(int, input().split()))
 
good = [True] * N
for m in range(0, M):
  A, B = map(int, input().split())
  if heights[A - 1] > heights[B - 1]:
    good[B - 1] = False
  elif heights[A - 1] < heights[B - 1]:
    good[A - 1] = False
    
count = 0
for obs in good:
  if obs: count += 1
    
print(count)

Submission status: Wrong Answer

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

goodObservatory = [1]*N
H = []
H = input()

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: Wrong Answer

Solution code:
N, M = map(int, input().split())
heights = list(map(int, input().split()))
 
good = [True] * N
for m in range(0, M):
  A, B = map(int, input().split())
  if A > B:
    good[B] = False
  elif A < B:
    good[A] = False
    
count = 0
for obs in good:
  if obs: count += 1
    
print(count)

Submission status: Wrong Answer

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 = [map(int, input().split()) for _ in range(M)]
    for a, b in AB:
        a-=1
        b-=1
        # if V[a] or V[b]:
        if H[a] < H[b]:
            V[a] = False
        else:
            V[b] = False
    
    print(V.count(True))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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())
  ah=h[a-1]
  bh=h[b-1]
  if ah>bh:
    anslist[b-1]=0
  else:
    anslist[a-1]=0
print(anslist.count(1))

Submission status: Wrong Answer

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

goodObservatory = [1]*N
goodObservatoryCount = 0

H = 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


goodObservatoryCount = sum(goodObservatory)

print(goodObservatoryCount)

Submission status: Wrong Answer

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 = [map(int, input().split()) for _ in range(M)]
    for a, b in AB:
        a = a - 1
        b = b - 1
        if V[a] or V[b]:
            if H[a] < H[b]:
                V[a] = False
            else:
                V[b] = False
    
    print(V.count(True))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:

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

goodObservatory = [1]*N
goodObservatoryCount = 0

H = 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


for i in range(N):
	if goodObservatory[i] == 1:
		goodObservatoryCount += 1

print(goodObservatoryCount)

Submission status: Wrong Answer

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

goodObservatory = [1]*N
goodObservatoryCount = 0

H = 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

for i in range(N):
	if goodObservatory[i] == 1:
		goodObservatoryCount += 1

print(goodObservatoryCount)

Submission status: Wrong Answer

Solution code:
H = []

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

goodObservatory = [1]*N
goodObservatoryCount = 0

H = 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

for i in range(N):
	if goodObservatory[i] == 1:
		goodObservatoryCount += 1

print(goodObservatoryCount)

Submission status: Wrong Answer

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



count = 0
for i in range(N):
    flag = 1
    for j in range(M):
        if(AB[j][0] == i):
            if(H[i] < H[AB[j][1] - 1]):
                flag = 0
        if(AB[j][1] == i):
            if(H[i] < H[AB[j][0] - 1]):
                flag = 0
    if(flag == 1):
        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 _ 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: Wrong Answer

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
    else:
        good[A - 1] += 1

        
print(good.count(0))

Submission status: Wrong Answer

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
  else:
    is_good[a-1] = False

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

print(cnt)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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)]
    '''
    hRelations = np.zeros((n, n))
    for a, b in ABList:
        if hList[a-1] >= hList[b-1]:
            hRelations[b-1, a-1] = 1
        if hList[b-1] >= hList[a-1]:
            hRelations[a-1, b-1] = 1
    total = 0
    print(total)
    for hRelation in hRelations:
        if hRelation.sum() == 0:
            total += 1
    print(total)
    '''


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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 max1 > H:
        cnt +=1        
print(cnt)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
h = list(map(int,input().split()))
d = [[0 for i in range(n)] for j in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    a,b = a-1,b-1
    d[a][b] = 1
    d[b][a] = 1
 
cnt = 0
for i in range(n):
    max1 = h[i]
    cnt_1 = 0
    for j in range(n):
        if d[i][j] == 1:
            cnt_1 +=1
            if h[j] > max1:
                max1 = h[j]
                break
    if max1 == h[i] and cnt_1 !=0:
        cnt +=1
print(cnt)

Submission status: Wrong Answer

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

tall=[0]*n

for i in range(m):
  if h[ab[i][0]-1]<h[ab[i][1]-1]:
    tall[ab[i][1]-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
    tall[ab[i][0]-1]=1
  else:
    tall[ab[i][1]-1]=0
    tall[ab[i][0]-1]=0
all_connect=''
for al in range(m):
  for con in str(ab[al]):
    all_connect+=str(con)
for counter in range(1,n+1):
  if str(counter) not in all_connect:
    tall[counter-1]=1
print(sum(tall))

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

tall=[0]*n

for i in range(m):
  if h[ab[i][0]-1]<h[ab[i][1]-1]:
    tall[ab[i][1]-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
    tall[ab[i][0]-1]=1
  else:
    tall[ab[i][1]-1]=0
    tall[ab[i][0]-1]=0
all_connect=''
for al in range(m):
  for j in range(2):
    for con in str(ab[al][j]):
      all_connect+=str(con)
for counter in range(1,n+1):
  if str(counter) not in all_connect:
    tall[counter-1]=1
print(sum(tall))

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
h = list(map(int,input().split()))
root = set()
for _ in range(m):
    s,g = map(int,input().split())
    path = tuple(sorted([s,g]))
    root.add(path)
print(n-len(root)+1)

Submission status: Wrong Answer

Solution code:
def maxx(ll:list):
    for i in range(len(ll)-1):
        m = max(int(ll[i]),int(ll[i+1]))
    return int(m)

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

wk =[1 for i in range(n)]
ab =[]
h=list(map(int,input().split()))
for i in range(m):
    ab.append(list(map(int,input().split())))
ab =list(map(list, set(map(tuple, ab))))

anab=[[0]  for i in range(n)]
for i in range(int(len(ab))):
    anab[ab[i][0]-1].append(int(h[ab[i][1]-1]))
    anab[ab[i][1]-1].append(int(h[ab[i][0]-1]))
for i in range(n):
    if len(anab[i]) == 1:
        wk[i]=0
    elif h[i]>maxx(anab[i]):
        wk[i]=0

print(wk.count(0))

Submission status: Wrong Answer

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
    elif H[A-1] > H[B-1]:
        good_H[B-1] = 0
    elif H[A-1] == H[B-1] and good_H[A-1] == 0 or good_H[B-1] == 0:
        good_H[A-1] = 0
        good_H[B-1] = 0

print(good_H.count(1))

Submission status: Wrong Answer

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

print(good_H.count(1))

Submission status: Wrong Answer

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())
counter = 0
a = set(A)
b = set(B)
for i in b:
    if i in a:
        counter += 0
    else:
        counter += 1

print(counter)

Submission status: Wrong Answer

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())
counter = 0
a = set(A)
b = set(B)
print(a,b,len(b))

for i in b:
    if i in a:
        counter += 0
    else:
        counter += 1

print(counter)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
H = list(map(int,input().split()))
A = [0]*M
B = [0]*M
for i in range(M):
  A[i],B[i]=map(int,input().split())
list = []
for i in range(M):
  if H[A[i]-1]>=H[B[i]-1]:
    list.append(B[i])
  elif 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: Wrong Answer

Solution code:
N,M=map(int,input().split())
H = list(map(int,input().split()))
A = [0]*M
B = [0]*M
for i in range(M):
  A[i],B[i]=map(int,input().split())
list = []
for i in range(M):
  if H[A[i]-1]>=H[B[i]-1]:
    list.append(B[i])
  elif 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: Wrong Answer

Solution code:
N,M=map(int,input().split())
H = list(map(int,input().split()))
A = [0]*M
B = [0]*M
for i in range(M):
  A[i],B[i]=map(int,input().split())
list = []
for i in range(M):
  if H[A[i]-1]>=H[B[i]-1]:
    list.append(B[i])
  else:
    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: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
# 高さ入力
h = list(map(int, input().split()))
a = [0]*m
b = [0]*m
for i in range(m):
    a[i], b[i] = map(int, input().split())
list = []
for i in range(m):
    if h[a[i]-1] > h[b[i]-1]:
        list.append(a[i])
    elif h[a[i]-1] == h[b[i]-1]:
        list.append(a[i])
        list.append(b[i])
    else:
        list.append(b[i])
# 答えを記録する用配列
listans = [0]*n
for i in range(len(list)):
    listans[list[i] - 1] += 1
ans = 0
for i in range(n):
    if listans[i] == 0:
        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[i], b[i] = map(int, input().split())
list = []
for i in range(m):
    if h[a[i]-1] > h[b[i]-1]:
        list.append(a[i])
    elif h[a[i]-1] == h[b[i]-1]:
        list.append(a[i])
        list.append(b[i])
    else:
        list.append(b[i])
# 答えを記録する用配列
listans = [0]*n
for i in range(len(list)):
    listans[list[i] - 1] += 1
ans = 0
for i in range(n):
    if listans[i] == 0:
        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[i], b[i] = map(int, input().split())
list = []
for i in range(m):
    if h[a[i]-1] > h[b[i]-1]:
        list.append(a[i])
    elif h[a[i]-1] < h[b[i]-1]:
        list.append(b[i])
    else:
        list.append(a[i])
        list.append(b[i])
# 答えを記録する用配列
listans = [0]*n
for i in range(len(list)):
    listans[list[i] - 1] += 1
ans = 0
for i in range(n):
    if listans[i] == 0:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
h = list(map(int,input().split()))
a = 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: Wrong Answer

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

Submission status: Wrong Answer

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
    
print (isGood.count(True))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split());
data = [input().split() for l in range(m+1)]
good = 0;
print(data);

a = 1;
while a <= n:
    
    b = 1;
    high = int(0);
    while b <= m:
        if int(data[b][0]) == a:
            p = int(data[b][1]);
            if int(data[0][p-1]) > high:
                high = int(data[0][p-1]);
        
        
        elif int(data[b][1]) == a:
            q = int(data[b][0]);
            if int(data[0][q-1]) > high:
                high = int(data[0][q-1]);
        b = b + 1;
    
    if int(data[0][a-1]) > high:
        good = good + 1;
    
    a = a + 1 ;

print(good);

Submission status: Wrong Answer

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
    else:
        A[a - 1] = 1
print(A.count(0))

Submission status: Wrong Answer

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

for _ in range(M):
  ab = list(map(int, input().split()))
  if ab not in AB:
    AB.append(ab)

n = 0
H2 = [0] * N

for _ in range(N):
  n += 1
  highest = max(H)
  i = H.index(highest)
  H[i] = 0
  if H2[i] == 0:
    H2[i] = 1
  del_path = [n for n, b in enumerate(AB) if i+1 in b]
  del_ind = [a[0]-1 if a[1]==i+1 else a[1]-1 for n, a in enumerate(AB) if n in del_path]
  AB = [a for i, a in enumerate(AB) if i not in del_path]
  H2 = [-1 if i in del_ind else h for i, h in enumerate(H2)]
print(H2.count(1))

Submission status: Wrong Answer

Solution code:
[N, M] = [int(x) for x in input().split()]
H = [int(x) for x in input().split()]
AB = []
for i in range(M):
	AB.append([int(x) for x in input().split()])
count = 0
for i in range(N): #展望台を総当たり
	bool = 1 #いい展望台だと1、違うと0
	for j in range(M): #道を総当たり
		if AB[j][0] == i+1:
			print(i,j,AB[j])
			if H[i] <= H[AB[j][1]-1]:
				bool = 0
				print(i,j,H[i],H[AB[j][1]-1])
		if AB[j][1] == i+1:
			print(i,j,AB[j])
			if H[i] <= H[AB[j][0]-1]:
				bool = 0
				print(i,j,H[i],H[AB[j][0]-1])
	if bool == 1:
		count = count + 1
print(count)

Submission status: Wrong Answer

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_highest = [1]*N
    m = defaultdict(list)
    for A,B in zip(Al,Bl):
        if Hl[A-1] > Hl[B-1]:
            is_highest[A-1] = 0
        else:
            is_highest[B-1] = 0
    print(sum(is_highest))
        

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

if __name__ == "__main__":
  run()

Submission status: Wrong Answer

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(m):
    ind2[ind[i]-1] += 1
ans = 0
for i in range(n):
    if ind2[i] == 0:
        ans += 1
print(ans)

Submission status: Wrong Answer

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])
    else:
        ind.append(b[i])
ind2 = [0] * n
for i in range(m):
    ind2[ind[i]-1] += 1
ans = 0
for i in range(n):
    if ind2[i] == 0:
        ans += 1
print(ans)

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())))
    
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:
        continue
        
ans=0
for x in ll:
    if x==0:
        ans+=1

print(ans)

Submission status: Wrong Answer

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

print(result.count(1))

Submission status: Wrong Answer

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
print(result)
print(result.count(1))

Submission status: Wrong Answer

Solution code:
from sys import stdin
N,M= list(map(int,stdin.readline().strip().split()))
H=[int(x) for x in input().split()]
road=[]
hig=[-1]*N
ans=[]
kari=[]
count=[0]*N
for i in range(M):
    road.append(list(map(int,input().split())))
for i,j in road:
    hig[i-1]=max(i,j)
    hig[j-1]=max(i,j)
if -1 in hig:
    print(len(set(hig))-1)
else:print(len(set(hig)))

#print(len(set(road)))

Submission status: Wrong Answer

Solution code:
from sys import stdin
N,M= list(map(int,stdin.readline().strip().split()))
H=[int(x) for x in input().split()]
road=[]
hig=[]
ans=[]
kari=[]
count=[0]*N
for i in range(M):
    road.append(max(list(map(int,input().split()))))
print(len(set(road)))

Submission status: Wrong Answer

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

tmp = [1] * N
max = 0

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(tmp)    
#tmp[H.index(max(H))] = 1
print(sum(tmp))

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
h=list(map(int,input().split()))
l=[]
for i in range(m):
  a,b=map(int,input().split())
  if h[a-1]<=h[b-1] and a not in l:
    l.append(a)
  elif h[a-1]>=h[b-1] and b not in l:
    l.append(b)
print(n-len(l))

Submission status: Wrong Answer

Solution code:
def maxx(ll:list):
    for i in range(len(ll)-1):
        m = max(ll[i],ll[i+1])
    return m

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

wk =[1 for i in range(n)]
ab =[]
h=list(map(int,input().split()))
for i in range(m):
    ab.append(list(map(int,input().split())))
ab =list(map(list, set(map(tuple, ab))))

anab=[[0]  for i in range(n)]

i=0
for i in range(len(ab)):
    anab[ab[i][0]-1].append(h[ab[i][1]-1])
    anab[ab[i][1]-1].append(h[ab[i][0]-1])
for i in range(n):
    if len(anab[i]) == 1:
        wk[i]=0
    elif h[i]>maxx(anab[i]):
        wk[i]=0

print(wk.count(0))

Submission status: Wrong Answer

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