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 random
import collections
# num_list = [10**5, 10**4]
# height_list = [random.randint(1, 10**9) for i in range(num_list[0])]
# way_list = [[random.randint(1, 10**5), random.randint(1, 10**5)] for i in range(10**4)]

num_list = [int(i) for i in input().split()]
height_list = [int(i) for i in input().split()]
way_list = list(list(map(int, input().split())) for i in range(num_list[1]))

tower_list = [i for i in range(1, num_list[0]+1)]
gd_dict = dict(zip(tower_list, ['good' for i in range(10**5)]))

def change_to_bad(target_list):
    if height_list[target_list[0]-1] > height_list[target_list[1]-1]:
        gd_dict[target_list[1]] = 'bad'
    elif height_list[target_list[0]-1] == height_list[target_list[1]-1]:
        gd_dict[target_list[0]] = 'bad'
        gd_dict[target_list[1]] = 'bad'
    else:
        gd_dict[target_list[0]] = 'bad'

for i in way_list:
    change_to_bad(i)

good_val = collections.Counter(gd_dict.values())['good']

good_val

Submission status: Wrong Answer

Solution code:


i = list(map(int, input().split())) 
j = list(map(int, input().split())) 

lis=[]
ans = 0
for a in range (i[0]):
    tendata=[a+1,j[a],0]
    lis.append(tendata)

for b in range(i[1]):
    miti = list(map(int, input().split()))
    if ((lis[miti[0]-1][1]) > (lis[miti[1]-1][1])):
        lis[miti[1]-1][2] = 1
    
    elif ((lis[miti[0]-1][1]) == (lis[miti[1]-1][1])):
        lis[miti[1]-1][2] = 1
        lis[miti[0]-1][2] = 1

    else:
        lis[miti[0]-1][2] = 1

for c in  lis:
    if not (c[2] == 1 ):
        print(c)
        ans = ans+1

        

print(ans)

Submission status: Wrong Answer

Solution code:


i = list(map(int, input().split())) 
j = list(map(int, input().split())) 

lis=[]
ans = 0
for a in range (i[0]):
    tendata=[a+1,j[a],0]
    lis.append(tendata)

for b in range(i[1]):
    miti = list(map(int, input().split()))
    if ((lis[miti[0]-1][1]) > (lis[miti[1]-1][1])):
        lis[miti[1]-1][2] = 1
    
    elif ((lis[miti[0]-1][1]) == (lis[miti[1]-1][1])):
        lis[miti[1]-1][2] = 1
        lis[miti[0]-1][2] = 1

    else:
        lis[miti[0]-1][2] = 1

print(lis)
for c in  lis:
    if not (c[2] == 1 ):
        print(c)
        ans = ans+1

        

print(ans)

Submission status: Wrong Answer

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

li = [0] + [-1] * N
for a, b in AB:
    ma = max(H[a-1], H[b-1])
    if ma==H[a-1]:
        li[b]=-4
    else:
        li[a]=-4
#     else:
#         li[a]=-4
#         li[b]=-4

#     if H[a-1]>H[b-1]:
#         li[b]=-4
#     elif H[b-1]>H[a-1]:
#         li[a]=-4
#     else:
#         li[a] = li[b] = -4

cnt=0

for i in range(N+1):
    if i==0:
        continue
    if li[i]==-4:
        cnt+=1
print(N-cnt)

Submission status: Wrong Answer

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

list = [0]*n
for j in range(m):
    if h[int(l[j][0])-1] > h[int(l[j][1])-1]:
        list[int(l[j][1])-1] -= 1
    elif  h[int(l[j][0])-1] < h[int(l[j][1])-1]:
        list[int(l[j][0])-1] -= 1
    else :
        list[int(l[j][0])-1] -= 1
        list[int(l[j][1])-1] -= 1

print(list)
print(list.count(0))

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]+1)
        count=0
        
        
        for i in A:
            if H[i[0]-1]>H[i[1]-1]:
                memo[i[0]]=H[i[0]-1]
                memo[i[1]]=H[i[0]-1]
            elif H[i[0]-1]==H[i[1]-1]:
                memo[i[0]]=H[i[0]-1]
            else:
                memo[i[0]]=H[i[1]-1]
                memo[i[1]]=H[i[1]-1]
                
        
        for i in range(NM[0]):
            if H[i]==memo[i+1]: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:
N,M=list(map(int, input().split()))
H=list(map(int, input().split()))
A=[list(map(int, input().split())) for _ in range(M)]
 
dp=[True]*N
a=[0]*N
 
for i in A:
  if H[i[0]-1]<H[i[1]-1] and a[i[1]-1]==0:
    dp[i[1]-1]=True
    dp[i[0]-1]=False
    a[i[0]-1]+=1
  elif H[i[0]-1]<H[i[1]-1] and a[i[1]-1]!=0:
    a[i[0]-1]+=1
    continue
  elif H[i[0]-1]>H[i[1]-1] and a[i[0]-1]==0:
    dp[i[1]-1]=False
    dp[i[0]-1]=True
    a[i[1]-1]+=1
  elif H[i[0]-1]>H[i[1]-1] and a[i[0]-1]!=0:
    a[i[1]-1]+=1
    continue
  elif H[i[0]-1]==H[i[1]-1]:
    dp[i[1]-1]=False
    dp[i[0]-1]=False
  
 
print(dp.count(True))

Submission status: Wrong Answer

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

li = [0] + [-1] * N
for a, b in AB:
    ma = max(H[a-1], H[b-1])
    if ma==H[a-1]:
        li[b]=-4
#     elif ma==H[b-1]:
#         li[a]=-4
    else:
        li[a]=-4
        li[b]=-4

#     if H[a-1]>H[b-1]:
#         li[b]=-4
#     elif H[b-1]>H[a-1]:
#         li[a]=-4
#     else:
#         li[a] = li[b] = -4

cnt=0

for i in range(N+1):
    if i==0:
        continue
    if li[i]==-4:
        cnt+=1
print(N-cnt)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
h = list(map(int,input().split()))
a = [0]*m
b = [0]*m
t = []
y = []
for i in range(m):
    a[i],b[i] = map(int,input().split())
    c = str(a[i])+" "+str(b[i])
    y.append(c)
t.extend(a)
t.extend(b)
s = [0]*m
count = 0
sw = [0]*n
z = set(y)
ab = list(z)
for i in range(len(ab)):
    a[i],b[i] = ab[i].split()
    a[i] = int(a[i])
    b[i] = int(b[i])
    if  h[a[i]-1] > h[b[i]-1] and sw[a[i]-1] == 0:
        if sw[b[i]-1] == 1 or sw[a[i]-1] == 1:
            count -= 1
        count += 1
        sw[a[i]-1] = 1
    elif h[a[i]-1] < h[b[i]-1] and sw[b[i]-1] == 0:
        if sw[a[i]-1] == 1 or sw[b[i]-1] == 1:
            count -= 1
        count += 1
        sw[b[i]-1] = 1
print(count+n-len(set(t)))

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
h = list(map(int,input().split()))
c = dict()
for i in range(m):
    a, b = map(int,input().split())
    if a in c:
        c[a].append(b)
    else:
        c[a] = [b]
    if b in c:
        c[a].append(a)
    else:
        c[b] = [a]
        
cnt = 0
for k,v in c.items():
    flag = 0
    for i in range(len(v)):
        if h[v[i] - 1] > h[k - 1]:
            flag = 1
            break
    if flag == 0:
        cnt += 1
print(cnt)

Submission status: Wrong Answer

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


    
    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from heapq import heappush, heappop

N, M = [int(v) for v in input().split()]

H = [int(v) for v in input().split()]

net = [set() for _ in range(N)]

for _ in range(M):
    a, b = [int(v) - 1 for v in input().split()]
    net[a].add(b)
    net[b].add(a)

q = []
for i, h in enumerate(H):
    heappush(q, (-h, i))

count = 0
closed = 0
while len(q) > 0:
    h, i = heappop(q)

    if closed & (1 << i) != 0:
        continue

    closed |= (1 << i)

    eq = False
    for j in net[i]:
        if H[j] == -h:
            eq = True
        closed |= (1 << j)
    if not eq:
        #        print(i, h, net[i])
        count += 1

print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

li = [0] + [-1] * N
for a, b in AB:
    ma = max(H[a-1], H[b-1])
    if ma==H[a-1]:
        li[b]=-4
    elif ma==H[b-1]:
        li[a]=-4
    else:
        li[a]=-4
        li[b]=-4

#     if H[a-1]>H[b-1]:
#         li[b]=-4
#     elif H[b-1]>H[a-1]:
#         li[a]=-4
#     else:
#         li[a] = li[b] = -4

cnt=0

for i in range(N+1):
    if i==0:
        continue
    if li[i]==-4:
        cnt+=1
print(N-cnt)

Submission status: Wrong Answer

Solution code:
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq
import itertools


#sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#INF = V * 10001
#A = [int(i) for i in input().split()]
#AB = [list(map(int, input().split())) for _ in range(K)]


N, M = map(int, input().split())
H = [int(i) for i in input().split()]
AB = [list(map(int, input().split())) for i in range(M)]
#s={AB[0][0]}
A = [0]*N
ans = 0
#print(H)


for i in range(M):
    #s.add(AB[i][0])
    #s.add(AB[i][1])
    #print(AB[i][0]-1, AB[i][1]-1)
    #print(H[AB[i][0]-1], H[AB[i][1]-1])
    if(H[AB[i][0]-1]==H[AB[i][1]-1]):
        A[AB[i][0]-1] =-1
        A[AB[i][1]-1] =-1
    elif(H[AB[i][0]-1]<H[AB[i][1]-1]):
        A[AB[i][0]-1] =-1
        #print(AB[i][1]-1)
        if(A[AB[i][1]-1] != -1):
            A[AB[i][1]-1] =1
    else:
        A[AB[i][1]-1] =-1
        if(A[AB[i][0]-1] != -1):
            A[AB[i][1]-1] =1

#print(A)
#print(s)
ans = A.count(0)+A.count(1)
#ans += N-len(s)


print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

list = [0]*n
for j in range(m):
    if h[int(l[j][0])-1] >= h[int(l[j][1])-1]:
        list[int(l[j][1])-1] -= 1
    else :
        list[int(l[j][0])-1] -= 1

print(list.count(0))

Submission status: Wrong Answer

Solution code:
N, M = input().split()
N = int(N)
M = int(M)
H = [int(x) for x in input().split()]

ans = [1] * N
load = [1] * N

for i in range(M):
    in1, in2 = input().split()
    in1 = int(in1)-1
    in2 = int(in2)-1
    load[in1] = 0
    load[in2] = 0
    if H[in1] < H[in2]:
        ans[in1] = 0
    elif H[in1] > H[in2]:
        ans[in2] = 0

index = 0
for i in load:
    if i == 1:
        ans[index] = 0
    index += 1
print(sum(ans))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
H_list = list(map(int, input().split()))
route_list = [list(map(int, input().split())) for m in range(M)]
frag_N = [True for i in range(N)]

for A, B in route_list:
    if H_list[A-1] < H_list[B-1]:
        frag_N[A-1] = False
        frag_N[B-1] = True
    elif H_list[A-1] > H_list[B-1]:
        frag_N[A-1] = True
        frag_N[B-1] = False
    else:
        frag_N[A-1] = False
        frag_N[B-1] = False

print(frag_N.count(True))

Submission status: Wrong Answer

Solution code:
def main():
    n, m = [int(x) for x in input().split()]
    heights = tuple(int(x) for x in input().split())
    checked = [1] * n
    for i in range(m):
        a, b = [int(x) - 1 for x in input().split()]
        if heights[a] < heights[b]:
            checked[a] = 0
        else:
            checked[b] = 0

    return sum(checked)


if __name__ == '__main__':
    print(main())

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,M = map(int, input().split())
H = list(map(int, input().split()))
import copy
max_H = copy.deepcopy(H)
max_ind = [0]*N

for _ in range(M):
  a,b = map(int, input().split())
  # path[a] += [b]
  if max_H[a-1] > H[b-1]:
    # max_H[a-1] = H[a-1]
    # print("A: {} {} H: {}".format(a-1, b-1, H[a-1]))
    if max_ind[a-1]==0:
      max_ind[a-1]=a-1
  elif max_H[a-1] < H[b-1]:
    max_H[a-1]=H[b-1]
    # print("B: {} {} H: {}".format(a-1, b-1, H[b-1]))
    max_ind[a-1]=b-1
  else:
    max_ind[a-1]=-1
  
  if max_H[b-1] > H[a-1]:
    # max_H[b-1]=H[b-1]
    # print("C: {} {} H: {}".format(a-1, b-1, H[b-1]))
    if max_ind[b-1]==0:
      max_ind[b-1]=b-1
  elif max_H[b-1] < H[a-1]:
    max_H[b-1]=H[a-1]
    # print("D: {} {} H: {}".format(a-1, b-1, H[a-1]))
    max_ind[b-1]=a-1
  else:
    max_ind[b-1]=-1

s = set(max_ind)
n = len(s)
if -1 in s:
  n -= 1

if 0 in s:
  n -=1
  n += max_ind.count(0)

print(n)
# print(max_ind)

Submission status: Wrong Answer

Solution code:
N,M = map(int, input().split())
H = list(map(int, input().split()))
res = [1]*N
for i in range(M):
    a,b = map(int, input().split())
    temp = min(H[a-1],H[b-1])
    res[H.index(temp)] = 0
print(res.count(1))

Submission status: Wrong Answer

Solution code:
# coding: utf-8

############################

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

for _ in range(m):
    ab = list(map(int,input().split()))
    h.discard(min(ab))
    
print(len(h))

Submission status: Wrong Answer

Solution code:


i = list(map(int, input().split())) 
j = list(map(int, input().split())) 

lis=[]
ans = 0
for a in range (i[0]):
    tendata=[a+1,j[a],0,]
    lis.append(tendata)

for b in range(i[1]):
    miti = list(map(int, input().split()))
    if ((lis[miti[0]-1][1]) > (lis[miti[1]-1][1])):
        lis[miti[1]-1][2] = 1
    else:
        lis[miti[0]-1][2] = 1


for c in  lis:
    if not (c[2] == 1 ):
        ans = ans+1
        

print(ans)

Submission status: Wrong Answer

Solution code:

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

for a, b in arr:
    highest_tenbo[a-1] = max(highest_tenbo[a-1], H[b-1])
    highest_tenbo[b-1] = max(highest_tenbo[b-1], H[a-1])

ans = 0
for i, t in enumerate(highest_tenbo):
  if not t < H[i]:
    ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
list_H = input().split()
list_N=list(range(1,N+1))
for i in range(M):
  A,B = map(int,input().split())
  if list_H[A-1]<list_H[B-1]:
    list_N[A-1]=0
  if list_H[A-1]>list_H[B-1]:
    list_N[B-1]=0
  if list_H[A-1]==list_H[B-1]:
    list_N[A-1]=0
    list_N[B-1]=0
num=0
for i in range(N):
  if list_N[i]!=0:
   
    num=num+1
print(num)

Submission status: Wrong Answer

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

list = [0]*n
for j in range(m):
    if l[j][0] >= l[j][1]:
        list[int(l[j][1])-1] -= 1
    else :
        list[int(l[j][0])-1] -= 1

print(list.count(0))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
H = list(map(int, input().split()))
C = [list(map(int, input().split())) for i in range(M)]
l = list()
cnt = 0
for i in range(N):
  for j in range(M):
    if i+1 in C[j] and H[C[j][0]-1] != H[C[j][1]-1]:
      l = l + [H[C[j][0]-1], H[C[j][1]-1]]
    elif i+1 in C[j] and H[C[j][0]-1] == H[C[j][1]-1]:
      cnt -= 1  
    else:
      pass
  print(l)
  if len(l) == 0:
    cnt += 1
  elif H[i] >= max(l):
    cnt += 1
  else:
    pass
  l = list()
print(cnt)

Submission status: Wrong Answer

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

for i in range(m):
    ai, bi = map(int, input().split())
    if h[ai-1] >= h[bi-1]:
        ans[bi-1] = 0
    elif h[ai-1] <= h[bi-1]:
        ans[ai-1] = 0
print(sum(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
N, M = map(int, input().split())
H = []
AB = []
H = input().split()

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

topH = set([])
lowH = set([])
rall = set((np.array(AB).flatten() - 1).tolist())
Hall = set(list(range(N)))
# print('rall', rall)
# print('Hall - rall', Hall - rall)

for i in range(M):
    AH = H[AB[i][0] - 1]
    BH = H[AB[i][1] - 1]
    # print(AB[i][0] - 1, AB[i][1] - 1)
    if AH > BH:
        topH.add(AB[i][0] - 1)
        lowH.add(AB[i][1] - 1)
    elif BH > AH:
        topH.add(AB[i][1] - 1)
        lowH.add(AB[i][0] - 1)
    else:
        lowH.add(AB[i][0] - 1)
        lowH.add(AB[i][1] - 1)

# print('topH', topH)
# print('lowH', lowH)

real_topH = (topH - lowH)
# print(topH)
tmp = (Hall) - rall
real_topH = real_topH | tmp

print(len(real_topH))

Submission status: Wrong Answer

Solution code:

i = list(map(int, input().split())) 
j = list(map(int, input().split())) 

lis=[]
ans = 0
for a in range (i[0]):
    tendata=[a+1,j[a],0,]
    lis.append(tendata)

for b in range(i[1]):
    miti = list(map(int, input().split()))
    if ((lis[miti[0]-1][1]) > (lis[miti[1]-1][1])):
        lis[miti[1]-1][2] = 1
    else:
        lis[miti[0]-1][2] = 1

print(lis)
for c in  lis:
    if not (c[2] == 1 ):
        ans = ans+1
        

print(ans)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
l=list(map(int,input().split()))
tmp=[0]*n

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

print(tmp.count(0))

Submission status: Wrong Answer

Solution code:
import sys
import collections
import itertools
import numpy as np

n,m = map(int, input().split())
al = np.ones(n,dtype="int8")
H = list(map(int, input().split()))
AB=[]

for i in range(m):
    AB.append(tuple(map(int, input().split())))

for t in range(m):
    A = AB[t][0]
    B = AB[t][1]
	
    bou1 = H[A-1]
    bou2 = H[B-1]
    if bou1<bou2:
        al[A-1] = al[A-1]-1
    elif bou2<bou1:
        al[B-1] = al[B-1]-1

print(np.count_nonzero(al>0))

Submission status: Wrong Answer

Solution code:
n,m=input().split()
h_list = []
h_list = input().split(" ")
result =[]
count = 0
for i in range(int(n)):
    result.append(True)
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
    else:
        pass
print(count)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
H = []
H = list(map(int,input().split()))
route = []
h_max = []
for i in range(M):
    route.append(list(map(int,input().split())))
for i in range(M):
    h_max.append(H.index(max(H[route[i][0]-1],H[route[i][1]-1])))
 
print(len(set(h_max)))

Submission status: Wrong Answer

Solution code:
import bisect
import collections
import sys

sys.setrecursionlimit(100000)
input = sys.stdin.readline
ACMOD = 1000000007
INF = 1 << 62


def lmi():
    return list(map(int, input().split()))


def llmi(n):
    return [lmi() for _ in range(n)]


N, M = lmi()
H = lmi()

AB = llmi(M)
flag = [1] * N
for a, b in AB:
    a = a - 1
    b = b - 1
    ha = H[a]
    hb = H[b]
    if ha >= hb:
        flag[b] = 0
    elif hb >= ha:
        flag[a] = 0
print(sum(flag))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
Hlist = list(map(int, input().split()))
ansdic = {}

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

ans = 0

for i in range(N):
    if i in ansdic:
        if ansdic[i]:
            ans += 1
    else:
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import collections
import itertools
import numpy as np

n,m = map(int, input().split())
al = np.ones(n,dtype="int8")
H = list(map(int, input().split()))
AB=[]

for i in range(m):
    AB.append(tuple(map(int, input().split())))

for t in range(m):
    A = AB[t][0]
    B = AB[t][1]
	
    bou1 = H[A-1]
    bou2 = H[B-1]
    if bou1<bou2:
        al[A-1] = al[A-1]-1
    elif bou2<bou1:
        al[B-1] = al[B-1]-1
    else:
        al[A-1] = al[A-1]-1
        al[B-1] = al[B-1]-1
print(np.count_nonzero(al>0))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import numpy as np

n, m = map(int, input().split())
h = np.array(input().split(), dtype='int')
bad_tower = []

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

    if ha > hb:
        bad_tower.append(b)
    elif ha < hb:
        bad_tower.append(a)
    elif ha == hb:
        bad_tower.append(a)
        bad_tower.append(b)

bad_tower = np.unique(bad_tower)

ans = n - len(bad_tower) + 1

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
Hlist = list(map(int, input().split()))
ansdic = {}

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

ans = 0

print(ansdic)

for i in range(N):
    if i in ansdic:
        if ansdic[i]:
            ans += 1
    else:
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
INF = 10**10
MOD = 10**9 + 7

N, M = map(int,input().split())
ok = [1] * N
H = list(map(int,input().split()))
for m in range(M):
    a, b = map(int,input().split())
    a-=1
    b-=1
    if H[a] < H[b]:
        ok[a] = 0
    elif H[a] > H[b]:
        ok[b] = 0
    # else:
    #     ok[a] = 0
    #     ok[b] = 0

print (sum(ok))

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
l=list(map(int,input().split()))
tmp=[0]*n

for i in range(m):
    flag=0
    a,b=map(int,input().split())

    if l[a-1] > l[b-1]:
        continue
    elif l[a-1] == l[b-1]:
        tmp[a-1]=-1
        tmp[b-1]=-1
    else:
        flag=1

    if flag==0:
        tmp[b-1]=-1
    if flag==1:
        tmp[a-1]=-1

print(tmp.count(0))

Submission status: Wrong Answer

Solution code:
from heapq import heappush, heappop

N, M = [int(v) for v in input().split()]

q = []
for i, h in enumerate([int(v) for v in input().split()]):
    heappush(q, (h, i))

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

for _ in range(M):
    a, b = [int(v) - 1 for v in input().split()]
    net[a].append(b)
    net[b].append(a)

count = 0
closed = 0
while q:
    h, i = heappop(q)

    if closed & (1 << i):
        continue

    count += 1
    closed |= (1 << i)

    for j in net[i]:
        closed |= (1 << j)

print(count)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
def main():
    N,M = map(int, input().split())
    H = list(map(int, input().split()))
    ans = []
    for _ in range(N):
        ans.append(1)
    for i in range(M):
        A,B = map(int, input().split())
        if H[A-1] < H[B-1]:
            ans[A-1] = -1
        elif H[A-1] > H[B-1]:
            ans[B-1] = 0
        else:
            ans[B-1] = 0
            ans[A-1] = 0
    print(sum(ans))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

for i in range(m):
    # if h[a[i]-1] == h[b[i]-1]:
    #     good[a[i]-1] = 0
    #     good[b[i]-1] = 0
    if h[a[i]-1] > h[b[i]-1]:
        if good[a[i]-1] <= h[a[i]-1]:
            good[a[i]-1] = h[a[i]-1]
            good[b[i]-1] = h[a[i]-1]
    else:
        if good[b[i]-1] <= h[b[i]-1]:
            good[a[i]-1] = h[b[i]-1]
            good[b[i]-1] = h[b[i]-1]

good = list(set(good))

if 0 in good:
    print(len(good)-1)
else:
    print(len(good))

Submission status: Wrong Answer

Solution code:
import math
from sys import stdin,stdout
#% 998244353
from heapq import heapify,heappop,heappush

import collections
# T = int(stdin.readline())
# for i in range(T):
    #N=int(stdin.readline())
N,M=list(map(int,stdin.readline().split()))
hill=list(map(int,stdin.readline().split()))

dc=collections.defaultdict(list)
#vis=set()
for m in range(M):
    A,B=list(map(int,stdin.readline().split()))
    dc[A].append(B)
    dc[B].append(A)

ans=0
for k,ls in dc.items():

    f=0
    z=0
    for h in ls:

        if hill[k-1] <= hill[h-1]:
            f=1
            break

    if not f:
      #  print(k)
        ans+=1  
#print(ans)
#ans+=(N-len(dc.keys()))
print(ans)

Submission status: Wrong Answer

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

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 i in range(m)]
w = []
l = []
for i in range(len(road)):
    if h[road[i][0]-1] > h[road[i][1]-1]:
        w.append(road[i][0])
        l.append(road[i][1])
    else:
        w.append(road[i][1])
        l.append(road[i][0])
w_ = set(w)
l_ = set(l)
for i in range(len(l_)):
    w_.discard(l[i])
print(len(w_))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, M = (int(i) for i in input().split(' '))
ten = [i+1 for i in range(N)]
H = [int(i) for i in input().split(' ')]
dic = {}
for i in range(len(H)):
    list_item = H[i]
    dic[i+1] = list_item
A = []
for i in range(M):
    x, y = (int(a) for a in input().split(' '))
    if dic[x] == dic[y]:
        A.append(x)
        A.append(y)
    if y in ten:
        A.append(y)
    else:
        A.append(x)
    
B = set(A)
for i in B:
    ten.remove(i)
print(len(ten))

Submission status: Wrong Answer

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

for i in range(M):
    a,b = map(int,input().split())
    m = max(H[a-1],H[b-1])
    ans.append(H.index(m))

print(len(set(ans)))

Submission status: Wrong Answer

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