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:
def make_heights_list(height):
    return [int(height), True]


tower_len, roads_len = map(int, input().split(' '))

heights = [[0, False]]
heights += (list(map(make_heights_list, input().split(' '))))

#print(heights)

# 塔を基準にして、その塔ごとに繋がる道をリストアップする
roads_highest = list()
for i in range(roads_len):
    start, end = map(int, input().split(' '))
    #print(start, end)
    if heights[start][1] is True and heights[end][0] >= heights[start][0]:
        heights[start][1] = False
        # ng_len += 1
    if heights[end][1] is True and heights[start][0] >= heights[end][0]:
        heights[end][1] = False
        # ng_len += 1

good_towers_len = 0
for tower in heights:
    if tower[1]:
        good_towers_len += 1

print(heights)

print(good_towers_len)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
N,M =map(int,input().split())
h_lis=np.array(list(map(int,input().split())))
way_lis=[list(map(int,input().split())) for _ in range(M)]
#print(way_lis)
tes=0
for i in range(N):
    nears=list([])
    for way in way_lis:
        if i+1 in way:
            nears.append(way)
    #print(len(np.array(nears).shape))
    if nears==[]:
        tes+=1
        break
    elif len(np.array(nears).shape)==1:
        #print(nears)
        h=max(h_lis[nears[0]-1],h_lis[nears[1]-1])
        if h==h_lis[i]:
            tes+=1
            break
        else:break
    else:
        pass
    #print(nears)
    for j,ne in enumerate(nears):
        if j==0:
            h=max(h_lis[ne[0]-1],h_lis[ne[1]-1])
            z=h
        else:
            k=z
            h=max(h_lis[ne[0]-1],h_lis[ne[1]-1])
            z=max(k,h)
    if z==h_lis[i]:
        tes+=1
print(tes)

Submission status: Wrong Answer

Solution code:
N,M =  map( int ,input().split())
H_list = list(map( int , input().split()))
A_B_list = [[0] * 2  for i in range(M)]
J_list = [0]*N
for i in range(M):
    A,B = map( int ,input().split())
    A_B_list[i][0] = A
    A_B_list[i][1] = B
for j in range(M):
    if H_list[A_B_list[j][0]-1] > H_list[A_B_list[j][1]-1]:
        J_list[A_B_list[j][0]-1] = 1
        J_list[A_B_list[j][1]-1] =-1
    elif H_list[A_B_list[j][0]-1] < H_list[A_B_list[j][1]-1]:
        J_list[A_B_list[j][0]-1] =-1
        J_list[A_B_list[j][1]-1] = 1
    else:
        J_list[A_B_list[j][0]-1] =-1
        J_list[A_B_list[j][1]-1] =-1
for l in range(N):
    if J_list[l] == 0:
        J_list[l] = 1
print(J_list.count(1))

Submission status: Wrong Answer

Solution code:
N, M= (int(x) for x in input().split())
height=[int(x) for x in input().split()]
nlist=[1]*N

for _ in range(M):
    a, b =(int(x) for x in input().split())
    a-=1
    b-=1
    if height[a]<height[b]:
        nlist[a]=0

    if height[b]<height[a]:
        nlist[b]=0

print(sum(nlist))

Submission status: Wrong Answer

Solution code:
l = list(map(int, input().split()))
li =  list(map(int, input().split()))

g = []
for i in range(l[1]):
    a, b = map(int, input().split())
    g += [min(a,b)]

g = set(g)
print(l[0] - len(g))

Submission status: Wrong Answer

Solution code:
N, M= (int(x) for x in input().split())
height=[int(x) for x in input().split()]
nlist=[1]*N
print(nlist)

for _ in range(M):
    a, b =(int(x) for x in input().split())
    a-=1
    b-=1
    if height[a]<height[b]:
        nlist[a]=0

    if height[b]<height[a]:
        nlist[b]=0
    print(nlist)

print(sum(nlist))

Submission status: Wrong Answer

Solution code:
def make_heights_list(height):
    return [height, True]


tower_len, roads_len = map(int, input().split(' '))

heights = [[0, False]]
heights += (list(map(make_heights_list, input().split(' '))))

#print(heights)

# 塔を基準にして、その塔ごとに繋がる道をリストアップする
roads_highest = list()
for i in range(roads_len):
    start, end = map(int, input().split(' '))
    #print(start, end)
    if heights[start][1] is True and heights[end][0] >= heights[start][0]:
        heights[start][1] = False
        # ng_len += 1
    if heights[end][1] is True and heights[start][0] >= heights[end][0]:
        heights[end][1] = False
        # ng_len += 1

good_towers_len = 0
for tower in heights:
    if tower[1]:
        good_towers_len += 1

print(good_towers_len)

Submission status: Wrong Answer

Solution code:
i = input()
i = i.split(' ')
l = []
while len(l)<int(i[0]):
  l += [0]

lim = int(i[1])

i = input()
i = i.split(' ')
for j in list(range(len(l))):
    i[j]=int(i[j])
print(i)

count=0
while count<lim:
    count += 1
    k = input()
    k = k.split(' ')
    if i[int(k[0])-1]==i[int(k[1])-1]:
        l[int(k[1])-1] = 1
        l[int(k[0])-1] = 1
    elif i[int(k[0])-1]>i[int(k[1])-1]:
        l[int(k[1])-1] = 1
    else:
        l[int(k[0])-1] = 1

count = 0
for j in l:
    if j==0:
        count += 1
print(count)

Submission status: Wrong Answer

Solution code:
def make_heights_list(height):
    return [height, True]


tower_len, roads_len = map(int, input().split(' '))

heights = [[0, False]]
heights += (list(map(make_heights_list, input().split(' '))))

print(heights)

# 塔を基準にして、その塔ごとに繋がる道をリストアップする
roads_highest = list()
for i in range(roads_len):
    start, end = map(int, input().split(' '))
    print(start, end)
    if heights[start][1] is True and heights[end][0] >= heights[start][0]:
        heights[start][1] = False
        # ng_len += 1
    if heights[end][1] is True and heights[start][0] >= heights[end][0]:
        heights[end][1] = False
        # ng_len += 1

good_towers_len = 0
for tower in heights:
    if tower[1]:
        good_towers_len += 1

print(good_towers_len)

Submission status: Wrong Answer

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


ans = [1] * n
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if hs[a] < hs[b]:
        ans[a] = 0
    elif hs[a] == hs[b]:
        ans[a] = 0
        ans[b] = 0
    else:
        ans[b] == 0

print(sum(ans))

Submission status: Wrong Answer

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

for i in range(M):

    A,B = map(int, input().split()) #一行ずつ処理

    if(H[A-1]>H[B-1]):
        preH[A-1] = 1
    if(H[B-1]>H[A-1]):
        preH[B-1] = 1

print(sum(preH))

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
h=[]
h.extend(input().split())
h=list(map(int,h))
cnt = [0]*n
cnt2 = [0]*n

for i in range(m):
  a,b = map(int,input().split())
  if h[a-1] >= h[b-1]:
    cnt[a-1] += 1  
  else:
    cnt[b-1] +=1
  
  cnt2[a-1] +=1
  cnt2[b-1] +=1
ans = 0
for p in range(n):
  if cnt[p]==cnt2[p]:
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
h = list(map(int,input().split()))
tenbo = [list(map(int,input().split())) for _ in range(m)]
#print(tenbo)
tree = [[0]for _ in range(n)]
for i in range(m):

	x = tenbo[i]
	x1 = x[0]
	x2 = x[1]
	#print(x1)
	y1 = h[x1-1]
	y2 = h[x2-1]
	a = [y1,y2]
	#print(x[1])
	tree[x[0]-1].extend(a)
	tree[x[1]-1].extend(a)
c = 0
for i in range(n):
	if max(tree[i]) <=h[i]:
		if len(tree[i]) != 1:
		#print(max(tree[i]))
			c += 1
print(c)

Submission status: Wrong Answer

Solution code:
a=input().split()
N=int(a[0])
M=int(a[1])
H=[int(x) for x in input().split()]
way=[]
for i in range(M):
    way.append([int(x) for x in input().split()])
print(way)
dic={}
for i in range(N):
    dic[i]=set()

for h in way:
    dic[h[0]-1].add(h[1]-1)
    dic[h[1]-1].add(h[0]-1)
    print(dic)

print(sum(all([H[i]>H[hs] for hs in dic[i]])for i in range(N)))

Submission status: Wrong Answer

Solution code:
## import

## function definition 

## main process
if __name__ == '__main__':
    
    ## input
    N, M = map(int,input().split())
    HEIGHT_LIST = list(map(int,input().split())) 
    ROAD_LIST = []
    for j in range(M): 
        ROAD_LIST.append(
            set(map(int,input().split()))
        )
    
    ## business logic
    COUNT = 0
    
    for i in list(range(1, N+1)):
        unioned_i = set([])
        for k in ROAD_LIST:
            if i in k:
                unioned_i = unioned_i | k
        if len(unioned_i) == 0:
            COUNT = COUNT + 1
            continue
        HIGHT_i = HEIGHT_LIST[i-1]
        if HIGHT_i >= max(
            [ HEIGHT_LIST[l-1] for l in list(unioned_i) ]
        ):
            COUNT = COUNT + 1
    
    ## output
    print(COUNT)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
h = list(map(int,input().split()))
tenbo = [list(map(int,input().split())) for _ in range(m)]
#print(tenbo)
tree = [[0]for _ in range(n)]
for i in range(m):

	x = tenbo[i]
	x1 = x[0]
	x2 = x[1]
	#print(x1)
	y1 = h[x1-1]
	y2 = h[x2-1]
	a = [y1,y2]
	#print(x[1])
	tree[x[0]-1].extend(a)
	tree[x[1]-1].extend(a)
c = 0
for i in range(n):
	if max(tree[i]) <=h[i]:
		#print(max(tree[i]))
		c += 1
print(c)

Submission status: Wrong Answer

Solution code:
import copy

def main():
  n,m = map(int,input().split())
  s = [int(n) for n in input().split()]
  cs = copy.copy(s)
  for i in range(m):
    a,b = map(int,input().split())
    a-=1
    b-=1
    if(s[a] < s[b]):
      cs[a] = -1
    elif(s[a] == s[b]):
      cs[a] = -1
      cs[b] = -1
    elif(s[b] < s[a]):
      cs[b] = -1
  print(cs)
  print()
  print(len(cs)-cs.count(-1))
      
if __name__ == '__main__':
  main()

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
F = [0] * N
for i in range(M):
    A[i], B[i] = map(int, input().split())
    F[A[i] - 1] = max(F[A[i] - 1], H[B[i] - 1])
    F[B[i] - 1] = max(F[B[i] - 1], H[A[i] - 1])

ans = 0
for i in range(N):
    if F[i] > H[i]:
        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
F = [0] * N
for i in range(M):
    A[i], B[i] = map(int, input().split())
    F[A[i] - 1] = max(F[A[i] - 1], H[B[i] - 1])
    F[B[i] - 1] = max(F[B[i] - 1], H[A[i] - 1])

ans = 0
for i in range(N):
    if F[i] >= H[i]:
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
## input
N, M = map(int,input().split())
HEIGHT_LIST = list(map(int,input().split())) 
ROAD_LIST = []
for j in range(M): 
    ROAD_LIST.append(
        set(map(int,input().split()))
    )

## business logic
COUNT = 0

for i in list(range(1, N+1)):
    unioned_i = set([])
    for k in ROAD_LIST:
        if i in k:
            unioned_i = unioned_i | k
    if len(unioned_i) == 0:
        COUNT = COUNT + 1
        continue
    HIGHT_i = HEIGHT_LIST[i-1]
    if HIGHT_i >= max(
        [ HEIGHT_LIST[l-1] for l in list(unioned_i) ]
    ):
        COUNT = COUNT + 1

## output
print(COUNT)

Submission status: Wrong Answer

Solution code:
import collections
N, M = map(int, input().split(' '))
H = list(map(int, input().split(' ')))
AB = [tuple(map(int, input().split())) for _ in range(M)]
good = [1] * N

for i in range(len(AB)):

    s1 = AB[i][0]
    s2 = AB[i][1]
    if H[s1-1] >= H[s2-1]:
        good[s2-1] -= 1
    else:
        good[s1-1] -= 1
print(good.count(1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

class abc_166:
    
    def __init__(self):
        pass
    
    def A(self):
        S=input()
        ans= "ARC" if S=="ABC" else "ABC"
        print(ans)
    
    def B(self):
        NK=list(map(int,input().split()))
        d=[]
        A=[]
        
        for i in range(NK[1]):
            d=int(input())
            a = list(map(int,input().split()))
            A.extend(a)
        
        print(NK[0]-len(list(set(A))))  
            
    def C(self):
        NM=list(map(int,input().split()))
        H=list(map(int,input().split()))
        A=[list(map(int,input().split())) for i in range(NM[1])]
        memo=[0]*(NM[0])
        count=0
        
        for i in range(len(memo)):memo[i]=H[i]
        
        #メモ化処理
        for i in A:
            if H[i[0]-1]>H[i[1]-1]:
                memo[i[0]-1]=H[i[0]-1]
                memo[i[1]-1]=H[i[0]-1]
            elif H[i[0]-1]==H[i[1]-1]:
                memo[i[0]-1]=0
                memo[i[1]-1]=0
            else:
                memo[i[0]-1]=H[i[1]-1]
                memo[i[1]-1]=H[i[1]-1]
                
        
        for i in range(NM[0]):
            if H[i]==memo[i]:count+=1
            else:pass
        
        print(count)
    
    
    def D(self):
        pass
    
    def E(self):
        pass
    
    def F(self):
        pass
    
    
if __name__=='__main__':
    obj=abc_166()
    obj.C()

Submission status: Wrong Answer

Solution code:
import numpy as np
n,m=map(int,input().split())
hlist = input().split()
ablist = []
for i in range(m):
    ablist.append(input().split())
x=np.zeros(n,int)
for ab in ablist:
  a=int(ab[0])
  b=int(ab[1])
  if hlist[a-1]<hlist[b-1]:
    x[a-1]=1#ダメ
  elif hlist[a-1]>hlist[b-1]:
    x[b-1]=1#ダメ
  elif hlist[a-1]==hlist[b-1]:
    x[a-1]=1
    x[b-1]=1
count=0
for l in range(n):
  if x[l]==0:
    count+=1
print(count)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split(" "))
l=list(map(int,input().split(" ")))
d={}
for i in l:
    d[i]=[]
count=0
for i in range(k):
    a,b=map(int,input().split(" "))
    s1=l[a-1]
    s2=l[b-1]
    d[s1].append(s2)
    d[s2].append(s1)
#print(d)
for key,val in d.items():
    if len(val)==0:
        count+=1
    for i in val:
       if key > i:
           count+=1
           break
    
print(count)

Submission status: Wrong Answer

Solution code:
import numpy as np
n,m=map(int,input().split())
hlist = input().split()
ablist = []
for i in range(m):
    ablist.append(input().split())
x=np.zeros(n,int)
for ab in ablist:
  a=int(ab[0])
  b=int(ab[1])
  if hlist[a-1]<hlist[b-1]:
    x[a-1]=1#ダメ
  elif hlist[a-1]>hlist[b-1]:
    x[b-1]=1#ダメ
  else:
    x[a-1]=1
    x[b-1]=1
count=0
for l in range(n):
  if x[l]==0:
    count+=1
print(count)

Submission status: Wrong Answer

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

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)]
for i in range(m):
  h[min(ab[i][0], ab[i][1])-1] = 0
  if h[ab[i][0]-1] == h[ab[i][1]-1]: h[ab[i][0]-1] = h[ab[i][1]-1] = 0
h = [i for i in h if i != 0]
print(len(h))

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)]
for i in range(m):
  h[min(ab[i][0]-1, ab[i][1]-1)] = 0
  if h[ab[i][0]-1] == h[ab[i][1]-1]: h[ab[i][0]-1] = h[ab[i][1]-1] = 0
h = [i for i in h if i != 0]
print(len(h))

Submission status: Wrong Answer

Solution code:
n,m=input().split()
h_list = []
h_list = input().split(" ")
result =[True]*int(n)
count = 0
for i in range(int(m)):
    temp1,temp2=input().split()
    if h_list[int(temp1)-1] < h_list[int(temp2)-1]:
        result[int(temp1)-1] = False
    elif h_list[int(temp1)-1] == h_list[int(temp2)-1]:
        result[int(temp1) - 1] = False
        result[int(temp2) - 1] = False
    else:
        result[int(temp2)-1] = False
for i in range(int(n)):
    if(result[i]==True):
        count += 1
print(count)

Submission status: Wrong Answer

Solution code:
def main():
  n,m = map(int,input().split())
  s = [int(n) for n in input().split()]
  cs = s
  for i in range(m):
    a,b = map(int,input().split())
    a-=1
    b-=1
    if(s[a] < s[b]):
      cs[a] = -1
    elif(s[a] == s[b]):
      cs[a] = -1
      cs[b] = -1
    elif(s[b] < s[a]):
      cs[b] = -1
  print(len(cs)-cs.count(-1))
      
if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
def main():
  n,m = map(int,input().split())
  s = [int(n) for n in input().split()]
  cs = s
  for i in range(m):
    a,b = map(int,input().split())
    a-=1
    b-=1
    if(s[a] < s[b]):
      cs[a]=-1
    elif(s[a] == s[b]):
      cs[a]=-1
      cs[b]=-1
    else:
      cs[b]=-1
  print(cs.count(-1))
      
if __name__ == '__main__':
  main()

Submission status: Wrong Answer

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

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

print(len(list(set(hlist))) + (len(H) - len(list(set(clist)))))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split(' '))
h = list(map(int, input().split(' ')))
c = [[] for i in range(n)]
dp = []
for i in range(m):
    a, b = map(int, input().split(' '))
    c[a - 1].append(h[b - 1])
    c[b - 1].append(h[a - 1])
    dp.append((a,b))
    if dp.count((a, b)) > 1:
        c[a - 1].append(pow(10,10))
r = 0
for i in range(n):
    if len(c[i]) == 0:
        r += 1
    else:
        if max(c[i]) < h[i]:
            r += 1

print(r)

Submission status: Wrong Answer

Solution code:
import collections
N, M = map(int, input().split(' '))
H = list(map(int, input().split(' ')))
AB = [tuple(map(int, input().split())) for _ in range(M)]
good = [1] * N

for i in range(len(AB)):

    s1 = AB[i][0]
    s2 = AB[i][1]
    if H[s1-1] > H[s2-1]:
        good[s2-1] -= 1
    else:
        good[s1-1] -= 1

#    print(good)

#for i in range(len(collections.Counter(H).most_common())):
#    if collections.Counter(H).most_common()[i][1] != 1:

print(good.count(1))

Submission status: Wrong Answer

Solution code:
nobs, nroads = [int(x) for x in input().strip().split()]
rec = [False]*(nobs+1)
hs = [int(x) for x in input().strip().split()]
d = {}
while nroads > 0:
  src, dst = [int(x) for x in input().strip().split()]
  if src not in d:
    d[src] = [dst]
  else:
    if dst not in d[src]:
      d[src].append(dst)
  if dst not in d:
    d[dst] = [src]
  else:
    if src not in d[dst]:
      d[dst].append(src)
  nroads -= 1
i = 0
total = 0
for i in range(0, nobs):
  src = i
  if src not in d:
    total += 1
    continue
  found = True
  for j in d[src]:
    #print(src, dst)
    dst = j-1
    if hs[src] <= hs[dst]:
      found = False
      break
  if found:
    total += 1
print(total)

Submission status: Wrong Answer

Solution code:
N, M, *I = map(int, open(0).read().split())
H, AB = [0] + I[:N], I[N:]

memo = [False] + [True] * N
for a, b in zip(*[iter(AB)] * 2):
    if H[a] < H[b]:
        memo[a] = False
    else:
        memo[b] = False

print(sum(memo))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
h = list(map(int, input().split()))
x = [{i} for i in range(n)]
best = 0

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

x = list(map(list, x))

for i in x:
    hi = list(map(lambda g: h[g], i))
    if max(hi) == h[x.index(i)] and hi.count(max(hi)) == 1:
        best += 1

print(best)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
h = list(map(int, input().split()))
maxh = []
for height in h:
    maxh.append(height)
for i in range(m):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    maxh[a] = max(maxh[a], h[b])
    maxh[b] = max(maxh[b], h[a])
g = 0
for height, maxheight in zip(h, maxh):
    if height == maxheight:
        g += 1
print(g)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
li=[0]*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]:
        if B in li:
            pass
        else:
            li[B-1]+=1
    elif H[A-1]<H[B-1]:
        if A in li:
            pass
        else:
            li[A-1]+=1
    else:
        if A in li and B in li:
            pass
        elif A in li:
            li[B-1]+=1
        elif B in li:
            li[A-1]+=1
        else:
            li[A-1]+=1
            li[B-1]+=1

print(li.count(0))

Submission status: Wrong Answer

Solution code:
import sys

lines = sys.stdin.readlines()

X = lines[0].split(' ')
N = int(X[0])
M = int(X[1])

H = []
Y = []*2

for i in range(N):
    H.append(int(lines[1].split(' ')[i]))

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)]
for i in range(m):
  h[min(ab[i][0]-1, ab[i][1])-1] = 0
h = [i for i in h if i != 0]
print(len(h))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

lines = sys.stdin.readlines()

X = lines[0].split(' ')
N = int(X[0])
M = int(X[1])

H = []
Y = []*2

for i in range(N):
    H.append(int(lines[1].split(' ')[i]))

for j in range(M):
    A = int(lines[j+2].split(' ')[0])
    B = int(lines[j+2].split(' ')[1])
    Y.append([A,B])

Y.sort()

Submission status: Wrong Answer

Solution code:
N,M =  map( int ,input().split())
H_list = list(map( int , input().split()))
A_B_list = [[0] * 2  for i in range(M)]
J_list = [0]*N
for i in range(M):
    A,B = map( int ,input().split())
    A_B_list[i][0] = A
    A_B_list[i][1] = B
for j in range(M):
    if H_list[A_B_list[j][0]-1] >= H_list[A_B_list[j][1]-1]:
        J_list[A_B_list[j][0]-1] = 1
        J_list[A_B_list[j][1]-1] =-1
    # elif H_list[A_B_list[j][0]-1] < H_list[A_B_list[j][1]-1]:
    else:
        J_list[A_B_list[j][0]-1] =-1
        J_list[A_B_list[j][1]-1] = 1
    # else:
    #     J_list[A_B_list[j][0]-1] =-1
    #     J_list[A_B_list[j][1]-1] =-1
for l in range(N):
    if J_list[l] == 0:
        J_list[l] = 1
print(J_list.count(1))

Submission status: Wrong Answer

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

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

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

graph = [[] for _ in range(N)]

for a, b in AB:
  a, b = a-1, b-1
  graph[a].append(b)
  graph[b].append(a)

  ans = 0

for i, h in enumerate(H):
  for to in graph[i]:
    if H[to] >= H[i]:
      break
    else:
      ans += 1
  
print(ans)

Submission status: Wrong Answer

Solution code:

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

AB = []
res = []

for _ in range(M):
    AB.append(sorted(list(map(int, input().split()))))

for i in range(1,N+1):
    for j in range(M):
        if AB[j][0] == i:
            if H[AB[j][0]-1] <= H[AB[j][1]-1]:
                break
    else:
        res.append(i)

print(len(res))

Submission status: Wrong Answer

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

height = [int(i) for i in input().split()]

tele = {}
for num, h in enumerate(height, 1):
    tele[num] = [h, "G"]

for roads in range(m):
    a, b = list(map(int, input().split()))
    if (tele[a][0] >= tele[b][0]):
        tele[b][1] = "N"
    elif (tele[a][0] <= tele[b][0]):
        tele[a][1] = "N"

ans_list = tele.values()
ans = 0
for a in ans_list:
    if (a[1] == "G"):
        ans += 1

print(ans)

Submission status: Wrong Answer

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

height = [int(i) for i in input().split()]

tele = {}
for num, h in enumerate(height, 1):
    tele[num] = [h, "G"]

for roads in range(m):
    a, b = list(map(int, input().split()))
    if (tele[a][0] >= tele[b][0]):
        tele[b][1] = "N"
    elif (tele[a][0] <= tele[b][0]):
        tele[a][1] = "N"

ans_list = tele.values()
print(ans_list)
ans = 0
for a in ans_list:
    if (a[1] == "G"):
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
H = list(map(int, input().split()))
s = [[0]]*n
 
for _  in range(m):
    road = list(map(int, input().split()))
    s[road[0]-1].append(H[road[1]-1])
    s[road[1]-1].append(H[road[0]-1])
 
c = 0
for j in range(n):
    if H[j] > max(s[j]):
        c+= 1
 
print(c)

Submission status: Wrong Answer

Solution code:

n,m = map(int,input().split())
l=[0]+list(map(int,input().split()))
d={}
for i in range(m):
    a,b=map(int,input().split())
    if a not in d:
        d[a]=[]
    if b not in d:
        d[b]=[]
    d[a].append(b)
    d[b].append(a)
cnt=0
for j in d:
    a=True
    r=l[j]
    for s in d[j]:
        if l[s]>r:
            a=False
            break
    if a:
        cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
N,M =  map( int ,input().split())
H_list = list(map( int , input().split()))
A_B_list = [[0] * 2  for i in range(M)]
J_list = [0]*N
for i in range(M):
    A,B = map( int ,input().split())
    A_B_list[i][0] = A
    A_B_list[i][1] = B
for j in range(M):
    if H_list[A_B_list[j][0]-1] > H_list[A_B_list[j][1]-1]:
        J_list[A_B_list[j][0]-1] = 1
        J_list[A_B_list[j][1]-1] =-1
    elif H_list[A_B_list[j][0]-1] < H_list[A_B_list[j][1]-1]:
        J_list[A_B_list[j][0]-1] =-1
        J_list[A_B_list[j][1]-1] = 1
    else:
        J_list[A_B_list[j][0]-1] =-1
        J_list[A_B_list[j][1]-1] =-1
for l in range(N):
    if J_list[l] == 0:
        J_list[l] = 1
print(J_list.count(1))

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
l=[0]+list(map(int,input().split()))
d={}
for i in range(m):
    a,b=map(int,input().split())
    if a not in d:
        d[a]=[]
    if b not in d:
        d[b]=[]
    d[a].append(b)
    d[b].append(a)
cnt=0
for j in d:
    a=True
    r=l[j]
    for s in d[j]:
        if l[s]>=r:
            a=False
            break
    if a:
        cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
H = list(map(int, input().split()))
s = [[0]]*n
 
for _  in range(m):
    a, b = map(int, input().split())
    s[a-1].append(H[b-1])
    s[b-1].append(H[a-1])
 
c = 0
for j in range(n):
    if H[j] > max(s[j]):
        c+= 1
 
print(c)

Submission status: Wrong Answer

Solution code:
import sys

lines = sys.stdin.readlines()

X = lines[0].split(' ')
N = int(X[0])
M = int(X[1])

H = []
Y = []

for i in range(N):
    H.append(int(lines[1].split(' ')[i]))

for j in range(M):
    A = int(lines[j+2].split(' ')[0])
    B = int(lines[j+2].split(' ')[1])
    if int(H[A-1]) <= int(H[B-1]):      
      Y.append(A-1)
    if int(H[B-1]) <= int(H[A-1]):
      Y.append(B-1)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
H = list(map(int,input().split()))
H = [0] + H
Tree = [0] + [1]*N
for _ in range(M):
  A,B = map(int,input().split())
  if H[A] >= H[B]:
    Tree[B] = 0
  else:
    Tree[A] = 0
print(sum(Tree))

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
H = list(map(int,input().split()))
H = [0] + H
Tree = [0] + [1]*N
for _ in range(M):
  A,B = map(int,input().split())
  if H[A] >= H[B]:
    Tree[B] = 0
  else:
    Tree[A] = 0
print(sum(H))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())  #数字
H = list(map(int, input().split()))#リスト
A = [list(map(int, input().split())) for i in range(M)]  #数字、複数行複数列

good = [True]*N
for i, j in A:
    print(i,j)
    i -= 1
    j -= 1
    if H[i] < H[j]:
        good[i] = False
    if H[i] > H[j]:
        good[j] = False
    if H[i] == H[j]:
        good[i] = False
        good[j] = False

print(good.count(True))

Submission status: Wrong Answer

Solution code:
N, M = map(int,input().split())
H = list(map(int,input().split()))
michi = [[] for i in range(N)]
 
for i in range(M):
    a,b = map(int,input().split())
    michi[a-1].append(b-1)
    michi[b-1].append(a-1)

 
ans = 0
for i in range(N): #i番目の展望台に注目
    if michi[i] == []:
        # print(i)
        ans +=1
    else:
        for j in michi[i]:
        # print(i,j,H[i],H[j]) 
        # このprintを消した
            if H[i] <= H[j]:
            #   不等号を直した
                break
            if j == michi[i][-1]:
                ans += 1
                # print(i)
 
print(ans)