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:
import numpy

inp=input().split(" ")
n=int(inp[0])
m=int(inp[1])
inh=input().split(" ")
for i in range(len(inh)):
  inh[i]=int(inh[i])
pairs=numpy.zeros(2*m,dtype=">i4").reshape(-1,2)
for i in range(m):
  a=input().split(" ")
  pairs[i][0]=int(a[0])
  pairs[i][1]=int(a[1])
lists=[[] for i in range(n+1)]
for i in range(len(pairs)):
  lists[pairs[i][0]-1].append(pairs[i][1]-1)
  lists[pairs[i][1]-1].append(pairs[i][0]-1)
for i in range(len(lists)):
  lists[i]=list(set(lists[i]))
count=0
for i in range(len(lists)):
  if len(lists[i])==0:
    count+=1
    print(i)
    continue
  for j in range(len(lists[i])):
    if inh[i] <= inh[lists[i][j]]:
      break
    if j == len(lists[i]):
      count+=1
      print(i)
print(count)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
Hs = list(map(int,input().split()))
outs = [1] * N
for _ in range(K):
    a,b = map(int,input().split())
    if Hs[a-1] == Hs[b-1]:
        outs[a-1] = 0 
        outs[b-1] = 0 
    elif Hs[a-1] > Hs[b-1]:
        Hs[b-1] = Hs[a-1]
        outs[b-1] = 0 
    else:
        Hs[a-1] = Hs[b-1]
        outs[a-1] = 0 
print(sum(outs))

Submission status: Wrong Answer

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

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

temp_h = h.copy()

for _ in range(m):
    x1, x2 = map(int,input().split())

    temp_h[x1 - 1] = max([temp_h[x1 - 1], h[x2 - 1]])
    temp_h[x2 - 1] = max([h[x1 - 1], temp_h[x2 - 1]])

res = [1 if x - y else 0 for x, y in zip(h, temp_h)]

print(sum(res))

Submission status: Wrong Answer

Solution code:
import numpy as np

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

ok=np.zeros(N)
for i in range(M):
    if H[A[i][0]-1]>H[A[i][1]-1]:
        ok[A[i][0]-1]=1
        ok[A[i][1]-1]=0
    else:
        ok[A[i][1]-1]=1
        ok[A[i][0]-1]=0
print(int(np.sum(ok)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
h = list(map(int,input().split()))
ans,a,b,c=[],[],[],[]
for i in range(m):
    A,B=map(int,input().split())
    a.append(A)
    b.append(B)
    c.append(A)
    c.append(B)
for i in range(1,n+1):
    t,k=0,0
    for j in range(m): 
        if a[j]==i or b[j]==i:
            if h[a[j]-1]>h[b[j]-1]:
                if t<h[a[j]-1]:
                    t=h[a[j]-1]
                    k=a[j]
            elif h[b[j]-1]>h[a[j]-1]:
                if t<h[b[j]-1]:
                    t=h[b[j]-1]
                    k=b[j]
    if k!=0:
        ans.append(k)
print(n-len(set(c))+len(set(ans)))

Submission status: Wrong Answer

Solution code:
import copy
N,M = map(int,input().split(' '))
H = list(map(int,input().split(' ')))
H_pop = copy.copy(H)
load_list = []
for i in range(M):
    load = list(map(int,input().split(' ')))
    load_list.append(load)
for i in load_list:
    A = H[int(i[0]-1)]
    B = H[int(i[1]-1)]
    try:
        if A < B:
            H_pop.remove(A)
        else:
            H_pop.remove(B)
    except ValueError:
        pass
print(len(H_pop))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
mounten_num, bridge_num = map(int, input().split())
mounten_higests = list(map(int, input().split()))
mounten_higests.sort(reverse=True)
bridges = []
good_mountens = []

# inputをさばく
for i in range(bridge_num):
    bridge = list(map(int, input().split()))
    bridge.sort()
    bridges.append(bridge)

# good_mountensとつながる橋がなければその山はgood_mounten
for j in mounten_higests:
    for k in good_mountens:
        if [j, k] in bridges:
            break
    else:
        good_mountens.append(j)

print(len(good_mountens))

Submission status: Wrong Answer

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

for i in range(m):
    a[i],b[i] = list(map(int, input().split(' ')))
    a[i] -= 1; b[i] -= 1
root = [[] for i in range(n)]

for i in range(m):
    root[a[i]] += [b[i]]
    root[b[i]] += [a[i]]

ret = [0 for i in range(n)]
for i,v in enumerate(root):
    flg = True
    for x in v:
        flg = True if h[i] > h[x] else False
    if flg:
        ret[i] += 1
print(sum(ret))

Submission status: Wrong Answer

Solution code:
def main():
    n, m = map(int, input().split())
    H = list(map(int, input().split()))
    p = [tuple(map(int, input().split())) for _ in range(m)]
    cnt = 0
    for i, h in enumerate(H):
        flag = True
        for a, b in p:
            if a != i and b != i:continue
            elif a == i:
                if h < H[b-1]:
                    flag = False
                    break
            elif b == i:
                if h < H[a-1]:
                    flag = False
                    break
        if flag:
            cnt += 1
    print(cnt)



if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N, M = map(int,input().split())
H_list = list(map(int,input().split()))
A_list = [0]*M
B_list = [0]*M
for i in range(M):
  A_list[i],B_list[i] = map(int,input().split())

count_list = ['+']*N
for j in range(M):
  if H_list[B_list[j]-1]-H_list[A_list[j]-1] >= 0:
    count_list[A_list[j]-1] = '-'
  else:
    count_list[A_list[j]-1] = '+'

for k in range(M):
  if H_list[A_list[k]-1]-H_list[B_list[k]-1] >= 0:
    count_list[B_list[k]-1] = '-'
  else:
    count_list[B_list[k]-1] = '+'
 
print(count_list.count('+'))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
sum = 0
height = list(map(int, input().split()))
road = []
for i in range(M):
  R = list(map(int, input().split()))
  road.append(R)

for i in range(N):
  p = 0
  for j in range(M):
    if road[j][0] == i:
      if height[road[j][0] - 1] <= height[road[j][1] - 1]:
        p += 1
    if road[j][1] == i:
      if height[road[j][1] - 1] <= height[road[j][0] - 1]:
        p += 1
  
  if p == 0:
    sum += 1

print(sum)

Submission status: Wrong Answer

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

a = list()
b = list()

for x in range(0, m):
    A, B = map(int, input().split())
    a.append(A)
    b.append(B)

check = [0]*n

for x, y in zip(a, b):
    if check[x-1] != 1:
        if h[x-1] > h[y-1]:
            check[x-1] = 1

        else:

            check[x-1] = -1
    if check[y-1] != 1:
        if h[x-1] < h[y-1]:
            check[y-1] = 1

        else:

            check[y-1] = -1

print(len(list(filter(lambda x: x != -1, check))))

Submission status: Wrong Answer

Solution code:
from collections import deque
n, m = map(int, input().split())
h = list(map(int, input().split()))
edges = [[] for i in range(n+1)]
for i in range(m):
    a, b = map(int, input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)
check = [0]*n
q = deque()
for i in range(n):
    q.append(i)
ans = 0
while q:
    print(q)
    print(check)
    node = q.pop()
    if check[node] != 0:
        continue
    else:
        check[node] = 1
        count = 0
        for v in edges[node]:
            q.append(v)
            if h[node] > h[v]:
                check[v] = 1
                count += 1
            elif h[node] == h[v]:
                check[v] = 1
        if count == len(edges[node]):
            ans += 1

print(edges)
print(ans)

Submission status: Wrong Answer

Solution code:
N, M = map(int,input().split())
AB = list()
good = [-1]*N
count = 0
H = list(map(int,input().split()))
for _ in range(M):
  ab = list(map(int,input().split()))
  AB.append(ab)
print(AB)
for i in range(M):
  if H[AB[i][0]-1] > H[AB[i][1]-1]:
    good[AB[i][1]-1] = -2
    good[AB[i][0]-1] = 0
  else:
    good[AB[i][0]-1] = -2
    good[AB[i][1]-1] = 0
for i in range(N):
  if good[i]==0:
    count = count + 1
print(good)
print(count)

Submission status: Wrong Answer

Solution code:
def main():
    n, m = [int(e) for e in input().split()]
    H = [int(e) for e in input().split()]
    AB = [[int(e) for e in input().split()] for i in range(m)]

    W = [0] * n
    for ab in AB:
        a, b = ab
        ha, hb = H[a - 1], H[b - 1]
        if ha > hb:
            W[a - 1] = 0
            W[b - 1] = 1

        elif ha < hb:
            W[a - 1] = 1
            W[b - 1] = 0

        else:
            W[a - 1] = 1
            W[b - 1] = 1

    print(W.count(0))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
H=list(map(int,input().split()))
A=[0]*M;cnt=0
for i in range(M):
  a,b=map(int,input().split())
  A[i]=a,b
A.sort(key=lambda x: x[0])
#print(A)
S=[-1]*(N+1)
for i in range(M):
  if H[A[i][0]-1]>H[A[i][1]-1]:
    S[A[i][0]]=1
  else:
    S[A[i][0]]=0

#print(S)
for i in range(M):
  if H[A[i][1]-1]>H[A[i][0]-1]:
    S[A[i][1]]=1
  else:
    S[A[i][1]]=0

#print(H)
#print(S)
for i in range(N+1):
  if S[i]==1 or S[i]==-1:
    cnt=cnt+1
print(max(0,cnt-1))

Submission status: Wrong Answer

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

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

yoi_warui = [0]*n
dokuritsu = [0]*n

for i in range(m):
    a, b = list(map(int, input().split()))
    dokuritsu[a-1] = 1
    dokuritsu[b-1] = 1
    if h[a-1] == h[b-1]:
        continue
    elif h[a-1] < h[b-1]:
        yoi_warui[a-1] = 1
    elif h[b-1] < h[a-1]:
        yoi_warui[b-1] = 1

print(yoi_warui.count(0)- dokuritsu.count(0))

Submission status: Wrong Answer

Solution code:
n, m = map(int,input().split())
h = list(map(int,input().split()))
dic = {}
for i in h:
    dic[i] = 0
for i in range(m):
    a, b = map(int,input().split())
    if a >= b:
        A = a
        a = b
        b = A
    dic[a] = 1
ans = 0
for i in h:
    if dic[i] == 0:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
h=list(map(int,input().split()))
h.insert(0,0)
s=set()
for i in range(m):
	a,b=map(int,input().split())
	s.add(a if h[a]<h[b]else b)
print(n-len(s))

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)]
s = [0]*n
for i in range(m):
    if h[a[i][0]-1] <= h[a[i][1]-1]:
        s[a[i][0]-1] += 1
    if h[a[i][0]-1] >= h[a[i][1]-1]:
        s[a[i][1]-1] += 1
ans = str(s)
print(ans.count('0'))

Submission status: Wrong Answer

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

s = set(range(N))
L = [-1] * N
for a, b in AB:
    if H[a - 1] < H[b - 1]:
        H[a - 1] = H[b - 1]
        L[a - 1] = b - 1
    elif H[a - 1] > H[b - 1]:
        H[b - 1] = H[a - 1]
        L[b - 1] = a - 1
    else:
        L[a - 1] = L[b - 1] = -1
    if a - 1 in s:
        s.remove(a - 1)
    if b - 1 in s:
        s.remove(b - 1)
# print(L)
R = set(L)

res = len(s) + len(R)
# print(len(s), len(R), R, s)
if -1 in R:
    res -= 1
print(res)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
h = list(map(int ,input().split()))
death = []
for i in range(k):
  a = list(map(int, input().split()))
  b = min(h[a[0]-1], h[a[1]-1])
  death.append(b)
#death = list(set(death))
for i in range(len(death)):
  if death[i] in h:
    h.remove(death[i])
print(len(h))

Submission status: Wrong Answer

Solution code:
import numpy as np

n, m = map(int, input().split())
h = np.array(list(map(int, input().split())))
g = [[] for _ in range(n)] 
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)

good_observatories = [-1] * n
sort_idx = np.argsort(-h)
for i, idx in enumerate(sort_idx):
    if i == 0:
        good_observatories[idx] = 1
        for v in g[idx]:
            good_observatories[v] = 0
    else:
        if good_observatories[idx] == -1:
            if all([h[idx] > h[v] for v in g[idx]]):
                good_observatories[idx] = 1
                for v in g[idx]:
                    good_observatories[v] = 0
print(good_observatories.count(1))

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    N, M = [int(item) for item in input().split()]

    H_list = [int(item) for item in input().split()]

    path_list = [[int(item) for item in input().split()] for _ in range(M)]

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

    for A, B in path_list:
        path_list2[A] += [B]
        path_list2[B] += [A]

    temp_list = []
    for item in path_list2:
        temp_list.append(list(set(item)))
    
    path_list2 = temp_list

    # print(path_list2)

    def nice(i):
        if len(path_list2[i]) >= 1:
            for j in path_list2[i]:
                if H_list[i-1] <= H_list[j-1]:
                    return False
                else:
                    return True
                
        else:
            return True


    cnt = 0
    for i in range(N):
        if nice(i+1):
            cnt += 1
            # print(i+1)
    
    print(cnt)


if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
H = list(map(int,input().split()))
memo = [[] for _ in range(N+1)]
for i in range(M):
    a,b = map(int,input().split())
    memo[a].append(b)
    memo[b].append(a)
    
count = 0
for i in range(1,N+1):
    #print(memo[i])
    if len(memo[i]) > 0:
        for j in memo[i]:
            if H[j-1] > H[i-1]:
                break
        else:
            #print(i)
            count += 1

print(count)
#print(memo)

Submission status: Wrong Answer

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

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

s = [list(map(int, input().split())) for i in range(m)]

cnt = 0
cnt = 0
cnt = 0
for hi in range(len(h)):
    flg = 'n'
    for sl in s:
        if hi == sl[0]:
            if h[hi] <= h[sl[1]-1]:
                flg = 'y'
                break
        if hi == sl[1]:
            if h[hi] <= h[sl[0]-1]:
                flg = 'y'
                break
    if flg == 'n':
#        print(hi, h[hi])
        cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
n, m = list(map(int, input().split()))
h_list = list(map(int, input().split()))
hh_list = [1] * n

for mm in range(m):
    a, b = list(map(int, input().split()))
    if h_list[a-1] - h_list[b-1] < 0:
        hh_list[a-1] = 0

counter = 0
for hh in hh_list:
    if hh >= 1:
        counter += 1
print(counter)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import collections
from collections import defaultdict

n,m=map(int,input().split())
h=[int(i) for i in input().split()]
graph=defaultdict(list)
for i in range(m):
    a,b=map(int,input().split())
    graph[a].append(b)
    graph[b].append(a)
count=0
print(graph)
for i in graph:
  for j in graph[i]:
      if h[j-1]>=h[i-1]:
          break
  else:
      count+=1
print(count)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
Hlist = list(map(int, input().split()))
ABList = []


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

anslist = [False]*N
for i in range(N):
    for ab in ABList:
        if ab[0] == i+1:
            if Hlist[ab[1]-1] >= Hlist[i]:
                anslist[i] = True
        if ab[1] == i+1:
            if Hlist[ab[0]-1] >= Hlist[i]:
                anslist[i] = True


print(anslist.count(True))

Submission status: Wrong Answer

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

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

tower=[0]*N

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

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
h = list(map(int,input().split()))
count = [0]* (n+1)
ans = [0]* n
ren = 1
result =0
for i in h:
    count[ren] = i
    ren += 1

for j in range(m):
    text = list(map(int,input().split()))
    if count[text[0]] < count[text[1]]:
        ans[text[0]-1] += 1
    else:
        ans[text[1]-1] += 1

for i in ans:
    if i == 0:
        result +=1
print(result)

Submission status: Wrong Answer

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


z = 0
l = [0]
for i in range(m):
  a,b = map(int,input().split())
  if (h[a-1]>h[b-1]):
    d = [a]
    l.extend(d)
  else:
    c = [b]
    l.extend(c)
for i in range(n):
  if l.count(i)==0:
    z = z + 1
print(z)

Submission status: Wrong Answer

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

h = {}

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

for (index, val) in enumerate(hs):
    h[index + 1] = val

bad = {}
for _ in range(0, m):
    a, b = map(int, input().split())
    ha, hb = [h[a], h[b]]

    if ha < hb:
        bad[ha] = 1
    if hb < ha:
        bad[hb] = 1

ans = 0

for x in hs:
    if x not in bad:
        ans += 1
        continue
    if bad[x]:
        continue
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
line = input().split(" ")
num = int(line[0])
road = int(line[1])
high = input().split(" ")
lowgroup = []
for i in range(road):
    a = input().split(" ")
    if int(high[int(a[0]) -1]) < int(high[int(a[1]) - 1]):
        lowgroup.append(a[0])
    else:
        lowgroup.append(a[1])
print(num - len(set(lowgroup)))

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
H = list(map(int,input().split()))
road = [list(map(int,input().split())) for r in range(M)]
seen = []
ans = []
for r in road:
	if H[r[0]-1] > H[r[1]-1]:
		ans.append(r[0])
	elif H[r[0]-1] < H[r[1]-1]:
		ans.append(r[1])
	if r[0] not in seen:
		seen.append(r[0])
	if r[1] not in seen:
		seen.append(r[1])

if len(seen) != N:
	print(len(set(ans))+(N-len(seen)))
else:
	print(len(set(ans)))

Submission status: Wrong Answer

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

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

print(n-h.count(0))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
H = list(map(int, input().split()))
A = [0] * M
B = [0] * M
G = [1] * N
for i in range(M):
    A[i], B[i] = map(int, input().split())
    me = A[i-1]
    t = B[i-1]
    if H[me-1] < H[t-1]:
        G[me-1] = 0

    me = B[i-1]
    t = A[i-1]
    if H[me-1] < H[t-1]:
        G[me-1] = 0
print(G.count(1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
H = [int(i) for i in input().split()]
A = []
for j in range(M):
  a, b = [int(i) for i in input().split()]
  if H[a-1] > H[b-1]:
    A.append(a)
  else:
    A.append(b)

A = list(set(A))
print(len(A))

Submission status: Wrong Answer

Solution code:
(n, m) = list(map(int, input().split()))
hights = list(map(int, input().split()))
tmap = {}
for i, h in enumerate(hights):
    tmap[i + 1] = h

nlist = list(range(1, n + 1))
for i in range(m):
    (s, d) = list(map(int, input().split()))
    if tmap[s] < tmap[d]:
        removal = s
    elif tmap[s] >= tmap[d]:
        removal = d
    if removal in nlist:
        nlist.remove(removal)
print(len(nlist))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
high = list(map(int, input().split()))
road = [list(map(int, input().split())) for i in range(M)]
p=[True for _ in range(N)]

for i in road:
    if high[i[0]-1]<=high[i[1]-1] and p[i[0]-1]==True:
        p[i[0]-1]=False
        
    elif high[i[0]-1]>=high[i[1]-1] and p[i[1]-1]==True:
        p[i[1]-1]=False

print(p.count(True))

Submission status: Wrong Answer

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

ans_set = set()
used_set = set()
lose_set = set()
for ab in ab_list:
    a = ab[0] - 1
    b = ab[1] - 1

    used_set.add(a)
    used_set.add(b)

    if h_list[a] == h_list[b]:
        continue
    if h_list[a] > h_list[b]:
        if not(a in lose_set):
            ans_set.add(a)
        lose_set.add(b)
    else:
        if not(b in lose_set):
            ans_set.add(b)
        lose_set.add(a)

for i in range(len(h_list)):
    if not(i in used_set):
        ans_set.add(i)
# print(ans_set)
print(len(ans_set))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

n, m = map(int, input().split())
yama = [1]*n
h = []
for i in input().split():
    h.append(i)
ab = []
for i in range(m):
    ab.append([int(i) for i in input().split()])

for i in ab:
    if h[i[0] - 1] > h[i[1] - 1]:
        yama[i[1] - 1] = 0
    elif h[i[0] - 1] < h[i[1] - 1]:
        yama[i[0] - 1] = 0
    else:
        yama[i[0] - 1] = 0
        yama[i[1] - 1] = 0

sum = 0
for i in yama:
    sum += i
print(sum)

Submission status: Wrong Answer

Solution code:
N,M= list(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())
ans = set([])
for i in range(M):
    a = A[i]-1
    b = B[i]-1
    if H[a] <= H[b]:
        ans.add(B[i])
    else:
        ans.add(A[i])
print(len(ans))

Submission status: Wrong Answer

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

for i in range(M):
  I = list(map(int, input().split()))
  A = I[0]
  B = I[1]
  betu.append(A)
  betu.append(B)
  if H[A-1] < H[B-1]:
    AA.append(B)
    if AA.count(A) != 0:
      AA.remove(A)
  elif H[A-1] > H[B-1]:
    AA.append(A)
    if AA.count(B) != 0:
      AA.remove(B)

print(len(list(set(AA))) + (N - len(list(set(betu)))))

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
li1 = list(map(int,input().split()))
grid = []
S = [0]*m
for i in range(m):
    array = list(map(int, input().strip().split()))
    grid.append(array)
for i in range(m):
    if li1[grid[i][0]-1] > li1[grid[i][1]-1]:
        S[i] += grid[i][0]
    else:
        S[i] += grid[i][1]
print(len(list(set(S))))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
h = [int(x) for x in input().split()]
L = [[] for i in range(n)]
ans = []
for i in range(m):
    a, b = input().split()
    if a not in L[int(b)-1]:
        L[int(b)-1].append(a)
    if b not in L[int(a)-1]:
        L[int(a)-1].append(b)
for j in range(n):
    M = []
    if len(L[j]) != 0:
        for k in L[j]:
            if int(k) < j:
                M.append(h[int(k)-1])
        if len(M) != 0 and max(M) not in ans:
            ans.append(max(M))
print(len(ans))

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
h = list(map(int,input().split()))
count = 0
for i in range(m):
    a,b = map(int,input().split())
    if a < b and a in h:
        h.remove(a)
    elif a > b and b in h:
        h.remove(b)

print(len(h))

Submission status: Wrong Answer

Solution code:
N, M = map(int,input().split())
H_list = list(map(float,input().split()))
A_list = [0]*M
B_list = [0]*M
for i in range(M):
  A_list[i],B_list[i] = map(int,input().split())

count_list = ['+']*N
for j in range(M):
  if H_list[B_list[j]-1]-H_list[A_list[j]-1] >= 0:
    count_list[A_list[j]-1] = '-'
  else:
    count_list[A_list[j]-1] = '+'

for k in range(M):
  if H_list[A_list[k]-1]-H_list[B_list[k]-1] >= 0:
    count_list[B_list[k]-1] = '-'
  else:
    count_list[B_list[j]-1] = '+'
 
print(count_list.count('+'))

Submission status: Wrong Answer

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

path = {i: [] for i in range(N+1)}
for _ in range(M):
  a,b = map(int, input().split())
  path[a] += [b]
  path[b] += [a]

def get_best(n):
  now = n
  tt = path[now] + [now]
  h = [H[i-1] for i in tt]
  h = sorted(h, reverse=True)
  if len(h) > 1:
    if h[-1] == h[-2]:
      return tt, False
    else:
      return tt, True
  else:
    return tt, True

      


n = 0
reached = []
for i in range(1,N+1):
  if i in reached:
    continue
  tmp_reache, same_flag = get_best(i)
  reached += tmp_reache
  if same_flag:
    n += 1

print(n)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
H=list(map(int,input().split()))
ans=0
A=[0]*N
path=[]
for i in range(M):
    a,b=map(int,input().split())
    path.append(a)
    path.append(b)
    if A[a-1]!=1 or A[b-1]!=1:
        if H[a-1]>H[b-1]:
            A[a-1]=1
            A[b-1]=-1
        elif H[a-1]<H[b-1]:
            A[b-1]=1
            A[a-1]=-1
        else:
            pass
    elif A[a-1]==1 and A[b-1]!=1:
        if H[a-1]<H[b-1]:
            A[a-1]=-1
            A[b-1]=1
        elif H[a-1]>H[b-1]:
            A[b-1]=-1    
    elif A[b-1]==1and A[a-1]!=1:
        if H[b-1]<H[a-1]:
            A[b-1]=-1
            A[a-1]=1
        elif H[b-1]>H[a-1]:
            A[a-1]=-1
    else:
        pass
path=set(path)
print(A.count(1)+N-len(path))

Submission status: Wrong Answer

Solution code:
N, M = [int(n) for n in input().split()]
H = [int(n) for n in input().split()]
ans = [0]*N
for i in range(M):
    AB = tuple([int(n) for n in input().split()])
    if H[AB[0]-1] > H[AB[1]-1]:
        ans[AB[0]-1] = 1
        ans[AB[1]-1] = -1
    else:
        ans[AB[0]-1] = -1
        ans[AB[1]-1] = 1
print(ans.count(1))

Submission status: Wrong Answer

Solution code:
def c():
    N, M = map(int, input().split())
    # H がグラフの頂点 0, 1, 2, 3, ..., N-1
    H = list(map(int, input().split()))

    # A,B が辺
    G = {}
    for i in range(M):
        A, B = map(int, input().split())
        G[A-1] = max(G.get(A-1, 0), H[B-1])
        G[B-1] = max(G.get(B-1, 0), H[A-1])
    cnt = 0
    # print(G)
    for j in range(N):
        if j in G.keys() and H[j] > G[j]:
            cnt += 1
    print(cnt)


##########
if __name__ == "__main__":
    c()

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
ans = [1]*n
h = input().split()
h_int = [int(s) for s in h]
cou = 0
 
for i in range(m):
  x,y = map(int,input().split())
  if h_int[x-1] >= h_int[y-1]:
    ans[y-1] = 0
  elif h_int[y-1] >= h_int[x-1]:
    ans[x-1] = 0
 
for i in range(n):
  if ans[i] == 1:
    cou += 1
 
print(cou)

Submission status: Wrong Answer

Solution code:
N, M = input().split()
height = input().split()
able = []
for n in range(int(N)):
  able.append([])
for m in range(int(M)):
  con = input().split()
  con[0] = int(con[0]) - 1
  con[1] = int(con[1]) - 1
  if not con[1] in able[con[0]]:
    able[con[0]].append(con[1])
  if not con[0] in able[con[1]]:
    able[con[1]].append(con[0])
good = []
for n in range(int(N)):
  if len(able[n]) == 0:
    good.append(n)
  else:
    point = 0
    for a in able[n]:
      if height[a] < height[n]:
        point += 1
    if point == len(able[n]):
      good.append(n)
print(len(good))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,M= list(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())
ans = set([])
for i in range(M):
    a = A[i]-1
    b = B[i]-1
    if H[a] <= H[b]:
        ans.add(B[i])
    else:
        ans.add(A[i])
len(ans)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
H=[int(x) for x in input().split()]
l=[1 for _ in range(N)]
for i in range(M):
  A,B=map(int,input().split())
  if H[A-1] < H[B-1]:
    l[A-1] = 0
  else:
    l[B-1] = 0
print(sum(l))