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


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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
l = input().split()
n = list()
H = list()
for i in range(N):
  H.append(int(l[i]))
  n.append(int(l[i]))
for i in range(M):
  Ai, Bi = map(int,input().split())
  if H[Ai-1] > H[Bi-1]:
    n[Bi-1] = 0
  else:
    n[Ai-1] = 0
r = 0
for i in range(N):
  if n[i] != 0:
    r += 1
print(r)

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(int, input().split()))
    if(height[obs_a - 1] > height[obs_b - 1]):
        isGood[obs_b - 1] = False
        height[obs_b - 1] = height[obs_a - 1]
    elif(height[obs_a - 1] < height[obs_b - 1]):
        isGood[obs_a - 1] = False
        height[obs_a - 1] = height[obs_b - 1]

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

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
h=list(map(int,input().split()))
ans=[True]*n

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

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
l = [int(x) for x in input().split()]
l_r = []
for i in range(m):
  a, b = map(int, input().split())
  c = min(l[a-1], l[b-1])
  if not c in l_r:
    l_r.append(c)
l_s = set(l)
l_r_s = set(l_r)
l_s_d = l_s ^ l_r_s
l_d = list(l_s_d)
print(len(l_d))

Submission status: Wrong Answer

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

from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement

N, M = [int(_) for _ in input().split()]
H = [int(_) for _ in input().split()]
AB = [[int(_) for _ in input().split()] for i in range(M)]

good = [0 for i in range(0, N)]

for i in AB:
    if i[0] > i[1]:
        good[i[0]-1] += 1
    elif i[1] > i[0]:
        good[i[1]-1] += 1

ct = 0
for j in good:
    if ct == 0:
        ct+=1

print(ct)

Submission status: Wrong Answer

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

from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement

N, M = [int(_) for _ in input().split()]
H = [int(_) for _ in input().split()]
AB = [[int(_) for _ in input().split()] for i in range(M)]

root = {i:[i] for i in range(1, N+1)}

for i in AB:
    root[i[0]].append(i[1])
    root[i[1]].append(i[0])

ct = 0
for j in range(0, N):
    b = [H[i-1] for i in root[j+1]]
    
    if len(b) == 1:
        ct += 1
        continue
    
    if max(b) == b[0] and len(list(set(b))) != 1:
        ct+=1

print(ct)

Submission status: Wrong Answer

Solution code:
result = 0
towers = {}
whole = []
bad = []
good = []

_in = [int(x) for x in input().split(' ')]
t_cnt = _in[0]
r_cnt = _in[1]

tmp = [int(x) for x in input().split(' ')]
for i in range(len(tmp)):
  towers[i+1] = tmp[i]

for i in range(r_cnt):
  vs = [int(x) for x in input().split(' ')]
  if towers[vs[0]] < towers[vs[1]]:
    bad.append(vs[0])
  else:
    bad.append(vs[1])

fix_bad = [x for x in set(bad)]
result = t_cnt - len(fix_bad)

print(result)

Submission status: Wrong Answer

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

from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement

N, M = [int(_) for _ in input().split()]
H = [int(_) for _ in input().split()]
AB = [[int(_) for _ in input().split()] for i in range(M)]

root = {i:[] for i in range(1, N+1)}

for i in AB:
    root[i[0]].append(i[1])
    root[i[1]].append(i[0])

for i in range(1, N+1):
    root[i] = list(set(root[i]))

ct = 0
for j in range(0, N):
    b = [H[i-1] for i in root[j+1]]
    b += [H[j]]
    if max(b) == H[j]:
        if len(b) == 1 or b.count(H[j]) != len(b):
            ct+=1

print(ct)

Submission status: Wrong Answer

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

ans=list(range(n))

for j in range(m):
    a,b=map(int,input().split())
    if(h[a-1]<h[b-1]):
        ans[a-1]=-1
    else:
        ans[b-1]=-1

print(sum([j>=0 for j in ans]))

Submission status: Wrong Answer

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

from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement

N, M = [int(_) for _ in input().split()]
H = [int(_) for _ in input().split()]
AB = [[int(_) for _ in input().split()] for i in range(M)]

root = {i:[] for i in range(1, N+1)}

for i in AB:
    root[i[0]].append(i[1])
    root[i[1]].append(i[0])

ct = 0
for j in range(0, N):
    b = [H[i-1] for i in root[j+1]]
    b += [H[j]]
    if max(b) == H[j]:
        if len(b) == 1 or b.count(H[j]) != len(b):
            ct+=1

print(ct)

Submission status: Wrong Answer

Solution code:
temp = input().split(" ")
N = int(temp[0])
M = int(temp[1])
H = input().split(" ")
good = [1] * N
for i in range(M):
    root = input().split(" ")
    a = int(root[0])-1
    b = int(root[1])-1
    if H[a]>=H[b]:
        good[b] = 0
    if H[a]<=H[b]:
        good[a] = 0

print(sum(good))

Submission status: Wrong Answer

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

ans=list(range(n))

for j in range(m):
    a,b=map(int,input().split())
    if(h[a-1]<h[b-1]):
        ans[a-1]=-1
    else:
        ans[b-1]=-1

print(sum([j>0 for j in ans]))

Submission status: Wrong Answer

Solution code:
if __name__ == "__main__":
  list_N_M = input().split(' ')
  N = int(list_N_M[0])
  M = int(list_N_M[1])
  
  list_str_H_all = input().split(' ')
  H = [0.0] * N
  for i in range(len(list_str_H_all)):
    H[i] = float(list_str_H_all[i])
  
  is_good_vp = [True] * N
  
  for _ in range(M):
    str_A_B = input().split(' ')
    A = int(str_A_B[0])
    B = int(str_A_B[1])
    
    if H[A-1] > H[B-1]:
      is_good_vp[B-1] = False
    elif H[B-1] > H[A-1]:
      is_good_vp[A-1] = False
    
  output = 0
  for i in range(N):
    if is_good_vp[i]:
      output += 1
      
  print(output)

Submission status: Wrong Answer

Solution code:
tower, road = map(int, input().split(" "))

towers = list(map(int, input().split(" ")))
goods = {i+1 for i in range(tower)}

for _ in range(road):
    tower_a, tower_b = map(int, input().split(" "))
    if towers[tower_a-1] > towers[tower_b-1]:
        goods.discard(tower_b)
    elif towers[tower_a-1] < towers[tower_b-1]:
        goods.discard(tower_a)
    else:
        goods.discard(tower_b)

print(len(goods))

Submission status: Wrong Answer

Solution code:
nm = list(map(int, input().split()))
n = nm[0]
m = nm[1]
h = list(map(int, input().split()))
good = [True] * n
for j in range(m):
    ab = list(map(int, input().split()))
    a = ab[0]
    b = ab[1]
    smaller_tower_index = a - 1 if h[a - 1] < h[b - 1] else b - 1
    if good[smaller_tower_index]:
        good[smaller_tower_index] = False
print(good.count(True))

Submission status: Wrong Answer

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

arrows = [True] * n

for road in roads:
    if heights[road[0] - 1] < heights[road[1] - 1]:
        res = [False, True]
    else:
        res = [True, False]
    arrows[road[0] - 1] &= res[0]
    arrows[road[1] - 1] &= res[1]

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
H = list(map(int,input().split()))
XX = [set() for i in range(N)]
ans = 0
for i in range(M):
  A,B = map(int,input().split())
  XX[A-1].add(B-1)
  XX[B-1].add(A-1)
  
for i in range(N):
  r = True
  for y in XX[i]:
    if H[i]<=H[y]:
      r = False
      break
    if r:
      ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
H = list(map(int,input().split()))
XX = [set() for i in range(N)]
ans = 0
for i in range(M):
  A,B = map(int,input().split())
  XX[A-1].add(B-1)
  XX[B-1].add(A-1)
  
for i in range(N):
  for y in XX[i]:
    r = True
    if H[i]<=H[y]:
      r = False
      break
    if r:
      ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
h = list(map(int, input().split()))
root = []
for i in range(m):
    root.append(list(map(int, input().split())))
count = 0
for elm in root:
    if h[elm[0]-1] > h[elm[1]-1]:
        count += 1
    elif h[elm[0]-1] < h[elm[1]-1]:
        count += 1
print(count)

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    [n,m] = [int(i) for i in input().split()]
    h = [int(i) for i in input().split()]
    d = dict()
    for i in range(n):
        d[i+1] = dict()
    for i in range(m):
        [a,b] = [int(i) for i in input().split()]
        if b in d[a].keys():
            d[a][b] = d[a][b] + 1
            d[b][a] = d[b][a] + 1
        else:
            d[a][b] = 1
            d[b][a] = 1
    count = 0
    for i in range(1,n+1,1):
        good = True
        for j in d[i].keys():
            if d[i][j] == 1:
                if h[i-1] <= h[j-1]:
                    good = False
                    break
            else :
                good = False
                break
        
        if good:
            # print(i)
            count+=1
    
    
    # print(d)
    print(count)

Submission status: Wrong Answer

Solution code:
import numpy as np
N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
G = N
lists = np.zeros(N)
for i in range(M):
    A, B = list(map(int, input().split()))
    if H[A-1] < H[B-1]:
        lists[A-1] = 1
    else:
        lists[B-1] = 1
for i in range(N):
    if lists[i] == 1:
        G -= 1
print(G)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
h = list(map(int, input().split()))
li = []
for m in range(M):
  a, b = map(int, input().split())
  if h[a-1] < h[b-1]:
    li.append(a)
  if h[a-1] == h[b-1]:
    li.append(a)
    li.append(b)
  else:
    li.append(b)

answer = N - len(set(li))
print(answer)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
h = list(map(int, input().split()))
li = []
for m in range(M):
  a, b = map(int, input().split())
  if h[a-1] < h[b-1]:
    li.append(a)
  if h[a-1] == h[b-1]:
    li.append(a)
    li.append(b)
  else:
    li.append(a)

answer = N - len(set(li))
print(answer)

Submission status: Wrong Answer

Solution code:
import numpy as np
N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
G = N
lists = np.zeros(N)
for i in range(M):
    A, B = list(map(int, input().split()))
    if H[A-1] < H[B-1]:
        lists[A-1] = 1
    else:
        lists[B-1] = 1
for i in range(N):
    if lists[i-1] == 1:
        G -= 1
print(G)

Submission status: Wrong Answer

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

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

t = set(count)
print(len(list(t)))

Submission status: Wrong Answer

Solution code:
n,m = input().split()
height = list(input().split())
list = []
for i in range(1,int(n)+1):
    list.append(i)
for i in range(int(m)):
    a,b = input().split()
    a = int(a)
    b = int(b)
    if int(height[a-1]) < int(height[b-1]):
        if int(a) in list:
            list.remove(a)
    elif int(height[a-1]) > int(height[b-1]):
        if int(b) in list:
            list.remove(b)
    elif int(height[a-1]) == int(height[b-1]):
        if int(b) in list:
            list.remove(b)
        elif int(a) in list:
            list.remove(a)
print(len(list))

Submission status: Wrong Answer

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

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

print(sum(height))

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

for i in range(m):
    hh = max(h[a[i]-1],h[b[i]-1])
    h[a[i]-1] = hh
    h[b[i]-1] = hh
print(len(set(h)))

Submission status: Wrong Answer

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

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

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

print(AB)
count = 0
for i in range(1,N+1):
    for ab in AB:
        print(ab)
        if ab[0] == i-1:
            if H[i-1] <= H[ab[1]-1]:
                continue
        if ab[1] == i-1:
            if H[i-1] <= H[ab[0]-1]:
                continue
    count += 1
print(int(count/2))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
n,m=map(int,input().split())
d=defaultdict(list)
l=list(map(int,input().split()))
for i in range(1,n):
	d[i].append(0)

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

count_obs=0
for keys,values in d.items():
	r=l[keys-1]
	count=0
	
	#print(r)
	#print(values)
	if len(values)==1:
		count_obs+=1
	else:
		for j in range(1,len(values)):
			if r>l[values[j]-1]:
				count+=1
		if count==len(values)-1:
			count_obs+=1


		
print(count_obs)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
n,m=map(int,input().split())
d=defaultdict(list)
l=list(map(int,input().split()))
for i in range(1,n):
	d[i].append(0)

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

count_obs=0
for keys,values in d.items():
	r=l[keys-1]
	count=0
	
	#print(r)
	#print(values)
	
	for j in range(len(values)):
		
		if values[j]==0:
			count+=1
		else:
			if r>l[values[j]-1]:
				count+=1
	if count==len(values):
		count_obs+=1


		
print(count_obs)

Submission status: Wrong Answer

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

for i in range(m):
    s,e = map(int,input().split())
    
    if h[s-1] > h[e-1]:
        mt[s-1] = 'good'
    else:
        mt[s-1] = 'bad'
    # mt[s-1] = 'good' if h[s-1] > h[e-1] else 'bad'
    
    if h[e-1] > h[s-1]:
        mt[e-1] = 'good'
    else:
        mt[e-1] = 'bad'

for i in mt:
    if (i == 0) or (i == 'good'):
        ans = ans + 1
        
print(ans)

Submission status: Wrong Answer

Solution code:
class Unionfind:
    decks = None
    Values = None

    def __init__(self, N, H):
        self.decks = [0 for i in range(int(N))]
        self.Values = [H[i] for i in range(int(N))]

    def Connect(self, A, B):
        if self.Values[int(A) - 1] > self.Values[int(B) - 1]:
            if self.decks[int(A) - 1] >= 0:
                self.decks[int(A) - 1] = 1
                self.decks[int(B) - 1] = -1
            else:
                self.decks[int(B) - 1] = -1
        elif self.Values[int(A) - 1] < self.Values[int(B) - 1]:
            if self.decks[int(B) - 1] >= 0:
                self.decks[int(B) - 1] = 1
                self.decks[int(A) - 1] = -1
            else:
                self.decks[int(A) - 1] = -1
        else:
            self.decks[int(A) - 1] = -1
            self.decks[int(B) - 1] = -1

    def GoodDeckCount(self):
        return len([i for i in self.decks if i >= 0])


N, M = input().split()
H = input().split()
j = [input().split() for i in range(int(M))]

uni = Unionfind(N, H)
for bridge in j:
    uni.Connect(bridge[0], bridge[1])

print(uni.GoodDeckCount())

Submission status: Wrong Answer

Solution code:
class Unionfind:
    decks = None
    Values = None

    def __init__(self, N, H):
        self.decks = [0 for i in range(int(N))]
        self.Values = [H[i] for i in range(int(N))]

    def Connect(self, A, B):
        if self.Values[int(A) - 1] > self.Values[int(B) - 1]:
            if self.decks[int(A) - 1] >= 0:
                self.decks[int(A) - 1] = 1
                self.decks[int(B) - 1] = -1
        elif self.Values[int(A) - 1] < self.Values[int(B) - 1]:
            if self.decks[int(B) - 1] >= 0:
                self.decks[int(B) - 1] = 1
                self.decks[int(A) - 1] = -1
        else:
            self.decks[int(A) - 1] = -1
            self.decks[int(B) - 1] = -1

    def GoodDeckCount(self):
        return len([i for i in self.decks if i >= 0])


N, M = input().split()
H = input().split()
j = [input().split() for i in range(int(M))]

uni = Unionfind(N, H)
for bridge in j:
    uni.Connect(bridge[0], bridge[1])

print(uni.GoodDeckCount())

Submission status: Wrong Answer

Solution code:
def input_map():
  return list(map(int, input().split(' ')))

data_list = input_map()
h_list = input_map()

load_list = []
for x in range(data_list[1]):
  tmp = input_map()
  load_list.append(tmp)
  load_list.append(list(reversed(tmp)))

good_list = []
nouse_list = list(range(1, data_list[0]))
for load in load_list:
  if load[0] in nouse_list:
    nouse_list.remove(load[0])
  if h_list[load[0]-1] > h_list[load[1]-1] and load[0] not in good_list:
    good_list.append(load[0])

print(len(good_list) + len(nouse_list))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
n,m=map(int,input().split())
d=defaultdict(list)
l=list(map(int,input().split()))
for i in range(m):
	a,b=map(int,input().split())
	d[a].append(b)
	d[b].append(a)

count_obs=0
for keys,values in d.items():
	r=l[keys-1]
	count=0
	for j in range(len(values)):
		if r>values[j]:
			count+=1
	if count==len(values):
		count_obs+=1
print(count_obs)

Submission status: Wrong Answer

Solution code:
class Unionfind:
    decks = None
    Values = None

    def __init__(self, N, H):
        self.decks = [0 for i in range(int(N))]
        self.Values = [H[i] for i in range(int(N))]

    def Connect(self, A, B):
        if self.Values[int(A) - 1] > self.Values[int(B) - 1]:
            self.decks[int(A) - 1] += 1
            self.decks[int(B) - 1] -= 2
        else:
            self.decks[int(B) - 1] += 1
            self.decks[int(B) - 1] -= 2

    def GoodDeckCount(self):
        return len([i for i in self.decks if i >= 0])


N, M = input().split()
H = input().split()
j = [input().split() for i in range(int(M))]

uni = Unionfind(N, H)
for bridge in j:
    uni.Connect(bridge[0], bridge[1])

print(uni.GoodDeckCount())

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
class Unionfind:
    decks = None
    Values = None
    def __init__(self, N, H):
        self.decks = [0 for i in range(int(N))]
        self.Values = [H[i] for i in range(int(N))]

    def Connect(self, A, B):
        if self.Values[int(A)-1] > self.Values[int(B)-1]:
            self.decks[int(A)-1] += 1
        else:
            self.decks[int(B)-1] += 1

    def GoodDeckCount(self):
        return len([i for i in self.decks if i > 0])


N, M = input().split()
H = input().split()
j = [input().split() for i in range(int(M))]

uni = Unionfind(N,H)
for bridge in j:
    uni.Connect(bridge[0], bridge[1])

print(uni.GoodDeckCount())

Submission status: Wrong Answer

Solution code:
def input_map():
  return list(map(int, input().split(' ')))

data_list = input_map()
h_list = input_map()

load_list = []
for x in range(data_list[1]):
  tmp = input_map()
  load_list.append(tmp)
  load_list.append(list(reversed(tmp)))

good_list = []
nouse_list = list(range(1, data_list[0]))
for load in load_list:
  if load[0] in nouse_list:
    nouse_list.remove(load[0])
  if h_list[load[0]-1] > h_list[load[1]-1]:
    good_list.append(load[0])

good_list = set(good_list)
print(len(good_list) + len(nouse_list))

Submission status: Wrong Answer

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

for i in range(m):
    a = list(map(int, input().split()))
    #print(a)
    #print(h)
    if h[a[0]-1] < h[a[1]-1]:
        A[a[0]-1] = 0
    else:
        A[a[1]-1] = 0

print(sum(A))

Submission status: Wrong Answer

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

for i in range(m):
    a = list(map(int, input().split()))
    #print(a)
    #print(h)
    if h[a[0]-1] < h[a[1]-1]:
        A[a[1]-1] = 0
    else:
        A[a[0]-1] = 0

print(sum(A))

Submission status: Wrong Answer

Solution code:
# 標準入力
n, m = map(int, input().split())
h_list = list(map(int, input().split()))
data = []
for _ in range(m):
    data.append( list(map(int, input().split())) )

ans_list = [1 for _ in range(n)]

for d in data:
    # 初期化
    d_0 = d[0] - 1
    d_1 = d[1] - 1

    if h_list[d_0] == h_list[d_1]:
        ans_list[d_0] = 0
        ans_list[d_1] = 0

    if h_list[d_0] > h_list[d_1]:
        ans_list[d_1] = 0

    if h_list[d_1] > h_list[d_0]:
        ans_list[d_0] = 0

print(*ans_list)
print(ans_list.count(1))

Submission status: Wrong Answer

Solution code:
def input_map():
  return list(map(int, input().split(' ')))

data_list = input_map()
h_list = input_map()

load_list = []
for x in range(data_list[1]):
  tmp = input_map()
  load_list.append(tmp)
  load_list.append(list(reversed(tmp)))

good_list = []
for load in load_list:
  if h_list[load[0]-1] <= h_list[load[1]-1]:
    good_list.append(load[0])

good_list = set(good_list)
print(len(good_list))

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,m=map(int, input().split())
    hl=[0]+list(map(int,input().split()))
    #どことも繋がっていない展望台もgoodだから、最後にTrueのままになっているのを数える
    checkl=[True]*n
    for i in range(m):
        a,b=map(int, input().split())
        if hl[a]<hl[b]:
            checkl[a-1]=False
        else:
            checkl[b-1]=False
    ans=0
    for i in range(n):
        if checkl[i]:
            ans+=1
    print(ans)
resolve()

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
h = list(map(int, input().split()))
list1 = [1] * n
for _ 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:
n,m = map(int, input().split())
h=list(map(int, input().split()))
good=[True]*n
for i in range(m):
  a,b = map(int, input().split())
  if h[a-1] >= h[b-1]:
    good[b-1]=False
  else:
    good[a-1]=False
ans=0
for i in good:
  if i:
    ans+=1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
O = list(map(int, input().split()))
B = [[] for i in range(N)]
 
for j in range(M):
  o_1, o_2 = map(int, input().split())
  B[o_1-1].append(o_2-1)
  B[o_2-1].append(o_1-1)
  
print(B)

ans = 0
for node in range(N):
  flag =1
  for l in B[node]:
    if O[node] <= O[l]:
      flag = 0
  if  flag ==1:
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
O = list(map(int, input().split()))
B = [[0 for i in range(N)] for j in range (N)]
 
for j in range(M):
  o_1, o_2 = map(int, input().split())
  B[o_1-1].append(o_2-1)
  B[o_2-1].append(o_1-1)
  
ans = 0
for node in range(N):
  flag =1
  for l in B[node]:
    if O[node] <= O[l]:
      flag = 0
  if  flag ==1:
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
O = list(map(int, input().split()))
B = [[0 for i in range(N)] for j in range (N)]
 
for j in range(M):
  o_1, o_2 = map(int, input().split())
  B[o_1-1].append(o_2-1)
  B[o_2-1].append(o_1-1)
  
ans = 0
for k in range(N):
  flag =1
  for l in B[k]:
    if O[k] <= O[l]:
      flag = 0
      break
    else:
      continue
  if  flag ==1:
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
input1 = input().rstrip().split(" ")
h = input().rstrip().split(" ")
yoi = [1 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]:
        yoi[b] = 0
    elif h[a] < h[b]:
        yoi[a] = 0
    else:
        yoi[a] = 0
        yoi[b] = 0
print (sum(yoi))

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][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] = 0
    elif h[a] < h[b]:
        # if  yoi[a] == 0:
        # yoi[a] = 1
        yoi[a] = 0
    else:
        # if  yoi[b] == 0:
            # yoi[b] = 1
        yoi[a] = 0
        yoi[b] = 0
print (sum(yoi))