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:
line = input().split(" ")

tenboudai = int(line[0])
load = int(line[1])

hyoko_list = input().split(" ")

win_list = []
load_tenboudai_list = []

for i in range(load):
    line_load = input().split(" ")
    left_load = int(line_load[0])
    right_load = int(line_load[1])
    load_tenboudai_list.extend([left_load,right_load]) #道に繋がれてる展望台リスト
    left_hyoko = hyoko_list[left_load - 1]
    right_hyoko = hyoko_list[right_load - 1]
    if (left_hyoko > right_hyoko):
        win_list.append(left_load)
    elif (left_hyoko < right_hyoko):
        win_list.append(right_load)

index = list(range(1,tenboudai))

output1 = set(win_list)
output2 = set(index) - set(load_tenboudai_list)

print(len(output1)+len(output2))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n, m = map(int, input().split())
h = [-1]+list(map(int, input().split()))
li = []
cnt = 0
for i in range(m):
    a, b = map(int, input().split())
    li.append([a, b])
for i in range(1, n+1):
    C = []
    f = 0
    q = -1
    for oc in li:
        if i in oc:
            if oc[0] != i:
                q = oc[0]
                if h[q] >= h[i]:
                    f = 1
            else:
                q = oc[1]
                if h[q] >= h[i]:
                    f = 1
    if f == 1:
        cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
import collections

n,m = map(int,input().split())
H = list(map(int,input().split()))
ans = []
cut =[]
for i in range(m):
  a,b = map(int,input().split())
  ans.append(a)
  ans.append(b)
  if a in cut:
    cut.append(a)
  else:
    cut.append(b)
  
ansset = set(ans)
cutset = set(cut)

print(len(ansset)-len(cutset))

Submission status: Wrong Answer

Solution code:
import copy

n,m = map(int,input().split())
h = [int(i) for i in input().split()]
ab = [input().split() for i in range(m)]

ans=copy.copy(h)
flag=1
while flag:
    flag=0
    tmp=[]
    for num, i in enumerate(ab):
        if h[int(i[0])-1]>h[int(i[1])-1]:
            tmp.append(num)
            flag=1
            ans[int(i[1])-1]=-1
        elif h[int(i[0])-1]<h[int(i[1])-1]:
            tmp.append(num)
            ans[int(i[1])-1]=-1
            flag=1
    tmp2=[]
    for i in range(len(ab)):
        if i not in tmp:
            tmp2.append(ab[i])
    ab=tmp2
ans1=0
for i in ans:
    if i>-1:
        ans1+=1
print(ans1)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
H = [int(i) for i in input().split()]
G = [0]*N
L = [1]*N

for i in range(M):
    A, B = map(int, input().split())
    L[A-1] = 0
    L[B-1] = 0

    if H[A-1]>H[B-1]: 
        G[A-1] = 1
        G[B-1] = 0
    elif H[A-1]<H[B-1]: 
        G[B-1] = 1
        G[A-1] = 0

# print(L)
# print(G)
print(G.count(1)+L.count(1))

Submission status: Wrong Answer

Solution code:
nm=input().split()
h=input().split()
ans=set(range(int(nm[0])))
for i in range(int(nm[1])):
    ab=input().split()
    a=int(ab[0])-1
    b=int(ab[1])-1
    if(h[a]>=h[b]):
        ans.discard(b)
    if(h[b]>=h[a]):
        ans.discard(a)
print(len(ans))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
H_list = list(map(int, input().split()))
root_list = []
for m in range(M):
    root_list.append(list(map(int, input().split())))

frag_N = [True for i in range(N)]
for A, B in root_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))
# print(frag_N)

Submission status: Wrong Answer

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

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())
h = list(map(int, input().split()))

f = [0] * 10 ** 5
c = {}
for i in range(m):
    a, b = map(int, input().split())
    if b < a:
        a, b = b, a
    if a not in c:
        c[a] = [b]
    else:
        c[a].append(b)


for k, v in c.items():

    if f[k] == 1:
        continue

    for i in v:
        if h[k-1] < h[i-1]:
            f[k-1] = 1
        elif h[k-1] > h[i-1]:
            f[i-1] = 1
        else:
            f[k-1] = 1
            f[i-1] = 1

ans = 0
for i in range(n):
    if f[i] == 0:
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
H = list(map(int, input().split()))
A = []
B = []
for i in range(M):
    A_, B_ = map(int, input().split())
    A.append(A_)
    B.append(B_)

l = [1] * N
for i in range(M):
    if H[A[i]-1] >= H[B[i]-1]:
        l[B[i]-1] = 0
    if H[A[i]-1] <= H[B[i]-1]:
        l[B[i]-1] = 0
print(sum(l))

Submission status: Wrong Answer

Solution code:
Ns,Ms,=input().split()
N=int(Ns)
M=int(Ms)
H=list(map(int,input().split()))
A=[]
B=[]
ans_arr=[]
for i in range(N):
    ans_arr.append(0)

for i in range(M):
    Ax,Bx=map(int,input().split())
    if H[Ax-1]<H[Bx-1]:
        ans_arr[Ax-1]=-1
    else:
        ans_arr[Bx-1]=-1

ans=0
for i in ans_arr:
    if i!=-1:
        ans+=1

print(ans)

Submission status: Wrong Answer

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

observatory_list = []

def process(a, b):
    global observatory_list
    
    for observatory in observatory_list:
        if a in observatory or b in observatory:
            observatory |= {a, b}
    else:
        observatory_list.append({a, b})
    
[process(*list(map(int, input().split()))) for _ in range(m)]

result = set()
for o in observatory_list:
    t = {i: hs[i-1] for i in list(o)}
    result.add(max(t, key=t.get))

print(len(result))

Submission status: Wrong Answer

Solution code:
import sys
import math
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix
import itertools
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
H = LIST()

L = []

for i in range(M):
    a, b = MAP()
    L.append([a, b])

flag = [1] * N

for i, j in L:
    if H[i-1] < H[j-1]:
        flag[i-1] = 0
    elif H[i-1] > H[j-1]:
        flag[j-1] = 0
    else:
        flag[i-1] = 0
        flag[j-1] = 0

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

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
listH=list(map(int,input().split()))
listN=[[0 for i in range(N)] for k in range(N)]
for i in range(M):
  A,B=map(int,input().split())
  if listH[A-1]>listH[B-1]:
    listN[A-1][B-1]=A
    listN[B-1][A-1]=A
  if listH[A-1]<listH[B-1]:
    listN[A-1][B-1]=B
    listN[B-1][A-1]=B
  else:
    listN[A-1][B-1]=-1
    listN[B-1][A-1]=-1
ans=0
for i in range(N):
  if len(set(listN[i]))==2 and (i+1 in set(listN[i])):
    ans+=1
  if len(set(listN[i]))==1:
    ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
a = list(map(int,input().split()))
n = a[0]
m = a[1]

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

mem = list(range(1,n+1))

for i in range(m):
  ab = list(map(int,input().split()))
  
  if h[ab[0]-1]>h[ab[1]-1]:
    if ab[1] in mem:
      mem.remove(ab[1])
      
  elif h[ab[0]-1]<h[ab[1]-1]:
    if ab[0] in mem:    
      mem.remove(ab[0])
  else:
    if ab[0] in mem:
      mem.remove(ab[0])
    elif ab[1] in mem:
      mem.remove(ab[1])
      
#print(mem)
print(len(mem))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
height = list(map(int, input().split()))
anslist = [1] * n
for x in range(m):
    a, b = map(int, input().split())
    if height[a - 1] < height[b - 1]: anslist[a - 1] = 0
    else: anslist[b - 1] = 0
print(sum(anslist))

Submission status: Wrong Answer

Solution code:
# C
import numpy as np

inp = input().split(' ')
N, M = int(inp[0]), int(inp[1])

inps = input().split(' ')
H = np.array([int(inp) for inp in range(len(inps))])
AB = []
for i in range(M):
    inps = input().split(' ')
    AB.append(set([int(inps[0]), int(inps[1])]))
    
def get_height(els):
    return H[els[0]-1] >= H[els[1]-1]

def get_height_sum(arr):
    return np.prod(list(map(get_height, arr)))

def tmp(arr_arr):
    return sum(list(map(get_height_sum, arr_arr)))

connected = [[[i+1] + list(ab - {i+1}) for ab in AB if i+1 in ab] for i in range(N)]

print(int(tmp(connected)))

Submission status: Wrong Answer

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

flag = [0 for _ in range(n)]
for i in range(m):

    
    a, b = map(int, input().split())

    a, b = a-1, b-1
    if a == b:
        continue
    elif h[a] == h[b]:
        flag[a] = -1
        flag[b] = -1
    elif h[a] < h[b]:
        if flag[a] == 1:
            flag[a] = -1
            flag[b] = 1
        elif flag[a] == -1:
            flag[b] = 1
        else:
            flag[a] = -1
            flag[b] = 1
    else:
        if flag[b] == 1:
            flag[a] = 1
            flag[b] = -1
        elif flag[b] == -1:
            flag[a] = 1
        else:
            flag[a] = 1
            flag[b] = -1
    
        
cnt = 0
for i in range(len(flag)):
    if flag[i]==1 or flag[i]==0:
        cnt += 1

print(cnt)

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
    elif 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)+ans.count(0))

Submission status: Wrong Answer

Solution code:
import itertools
def rren(): return list(map(int, input().split()))
n,m=rren()
hl=[0] +rren()
al=[tuple(input().split()) for i in range(m)]
ans=[]
for r in al:
    tallt=max(hl[int(r[0])], hl[int(r[1])])
    if tallt not in ans:
        ans.append(tallt)
    if hl[int(r[0])] == hl[int(r[1])]:
        continue
    lowt=min(hl[int(r[0])], hl[int(r[1])])
    if lowt in ans:
        ans.remove(lowt)

print(len(ans))

Submission status: Wrong Answer

Solution code:
import copy
N, M = map(int, input().split())
H = list(map(int, input().split()))
RH = copy.copy(H)
for j in range(M):
  a, b = map(int, input().split())
  ah = H[a-1]
  bh = H[b-1]
  if ah >= bh: RH[b-1] = 0
  else: RH[a-1] = 0
ans = list(set(RH))
print(len(ans)-1)

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 and 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 and 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:
a = input().split(" ")
N = eval(a[0])
M = eval(a[1])
b = input().split(" ")
hight_lst = list(map(eval, b))
lst = []
for i in range(N):
    lst.append([])

for i in range(M):
    c = input().split(" ")
    lst[eval(c[0])-1].append(eval(c[1])-1)
    lst[eval(c[1])-1].append(eval(c[0])-1)
    
count = 0
for i in range(0, N):
    if lst[i] == []:
        count += 1

    else:
        for j in lst[i]:
            if hight_lst[j] >= hight_lst[i]:
                break
            else:
                count += 1
                break


print(count)

Submission status: Wrong Answer

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

for __ in range(M):
    A, B = map(int,input().split())

    if H[A - 1] < H[B - 1]:
        flag[A - 1] = 0
    elif H[A - 1] < H[B - 1]:
        flag[B - 1] = 0
    elif H[A - 1] == H[B - 1]:
        flag[A - 1] = 0
        flag[B - 1] = 0
        
print(sum(flag))

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())
print(A)
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(lst)
print(sum(lst))

Submission status: Wrong Answer

Solution code:
N,M = map(int, input().split())
Hs = list(map(int, input().split()))
i = 0
ABs = []
while True:
  if M <= i:
    break
  ABs.append(list(map(int, input().split())))
  i += 1
r = [0] * N

for A, B in ABs:
  if Hs[A-1] <= Hs[B-1]:
    r[A-1] = -1
  else:
    r[A-1] = 0
  if Hs[B-1] <= Hs[A-1]:
    r[B-1] = -1
  else:
    r[B-1] = 0
print(r.count(0))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
h = list(map(int, input().split()))
j=[]
def flatten(nested_list):
    """2重のリストをフラットにする関数"""
    return [e for inner_list in nested_list for e in inner_list]
for i in range(m):
    j.append(list(map(int, input().split())))
total=0
for t in range(n):
    highest = h[t]
    temp=0
    pickup=[]
    for s in range(m):
        if  t+1 in j[s]:
            pickup.append(j[s])
    if len(pickup)>0:
    	pickup=flatten(pickup)
    	pickup=list(set(pickup))
    	pickup.remove(t+1)
    	for n in pickup:
      		if h[n-1]>highest:
        		temp=1
        		break
    if temp==0:
      total+=1
print(total)

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())
#a=input()
li1=list(map(int,input().split()))
li2=li1
li=[1]*a
li3=[list(map(int,input().split())) for i in range(b)]
#print(li2)
#print(li3)
for x,y in li3:
    #print(x)
    if li2[x-1]>li2[y-1]:
        li[y-1]=0
        #print(x,y)
        #print(li2[x-1],li2[y-1])
        #print(li)
        li1[y-1]=li1[x-1]

    elif li2[x-1]<li2[y-1]:
        li[x-1]=0
        #print(x,y)
        #print(li2[x-1],li2[y-1])
        #print(li)
        li1[x-1]=li1[y-1]
    else:
        #print(x,y)
        #print(li2[x-1],li2[y-1])
        pass

#print(li2)
#print(li1)
#print(li)
print(len(list(set(li1))))

Submission status: Wrong Answer

Solution code:
# ABC166 C

def main():
    n, m = map(int, input().split())
    H = list(map(int, input().split()))
    
    towers = []
    for _ in range(n):
        towers.append([])
    
    good_tower_count = 0

    for _ in range(m):
        a, b = map(int, input().split())
        #print(a, b)
        towers[a-1].append(b-1)
        towers[b-1].append(a-1)
        #print(towers)
    
    # for each of the towers
    for i in range(n):
        good_flag = False

        # check if the tower is taller than the neighbour towers
        for j in range(len(towers[i])):
            if H[i] > H[towers[i][j]]:
                good_flag = True
        
        if good_flag or len(towers[i]) == 0:
            good_tower_count += 1
            #print(i)
    
    print(good_tower_count)
    


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
h_list=list(map(int,input().split()))
col_list=[[0]*n for _ in range(n)]
count=0
for _ in range(m):
  a,b=map(int,input().split())
  col_list[a-1][b-1]+=1

for i in range(n):
  for j in range(n):
    if col_list[i][j]>=1 and h_list[i]<=h_list[j]:
      count+=1
      break
print(n-count)

Submission status: Wrong Answer

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

H = input().split()
H2 = [0] * N
for i in range(K):
    a, b = map(int, input().split())
    if H[a-1] > H[b-1]:
        H2[b-1] = 1
    elif H[a-1] < H[b-1]:
        H2[a-1] = 1
    elif H[a-1] == H[b-1]:
        H2[b-1] = 1
        H2[a-1] = 1

count = 0
for i in H2:
    if i == 0:
        count+=1
print(count)

Submission status: Wrong Answer

Solution code:
import sys
import math
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix
import itertools
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
H = LIST()

L = []

for i in range(M):
    a, b = MAP()
    L.append([a, b])

flag = [1] * N

for i, j in L:
    if H[i-1] < H[j-1]:
        flag[i-1] = 0
    elif H[i-1] > H[j-1]:
        flag[j-1] = 0
    else:
        flag[i-1] = 0
        flag[j-1] = 0

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

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

t={}
for i in range(n):
    t[i+1]=0
for x in ab:
    if h[x[0]-1] >= h[x[1]-1]:
        t[x[1]] = t[x[1]]+1
    elif h[x[0]-1] <= h[x[1]-1]:
        t[x[0]] = t[x[0]]+1
c = 0
allZero = True
for y in t.values():
    if y==0:
        c += 1
    else:
        allZero = False
if c>0:
    print(c)
else:
    if allZero:
        print(n)
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
N, M = map(int, input().split())
H = list(map(int, input().split()))
AB = [list(map(int, input().split())) for i in range(M)]
d = defaultdict(set)

for i in range(M):
    d[H[AB[i][0]-1]].add(H[AB[i][1]-1])
    d[H[AB[i][1]-1]].add(H[AB[i][0]-1])

cnt = 0
n = len(set(H)) - len(d)
cnt += n
for k, v in d.items():
    if k > max(v):
        cnt += 1

print(cnt)

Submission status: Wrong Answer

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

c_arr = []
for i in H:
    c_arr.append(False)

for i in range(M):
    a_, b_ = map(int, input().split())
    if H[a_-1] > H[b_-1]:
        c_arr[a_-1] = True
        c_arr[b_-1] = False
    elif H[a_-1] < H[b_-1]:
        c_arr[b_-1] = True
        c_arr[a_-1] = False

c = 0
for i in c_arr:
    if i:
        c = c + 1

print(c)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split(" "))
H = input().split(" ")
for i in range(N):
  H[i]=[int(H[i]),1]
for j in range(M):
  A,B = map(int,input().split(" "))
  if H[A-1][0]>=H[B-1][0]:
    H[B-1][1]=0
  else:
    H[A-1][1]=0
compte=0
for k in range(N):
  if H[k][1]==1:
    compte+=1
print(compte)

Submission status: Wrong Answer

Solution code:
N,M = map(int, input().split())
H = list(map(int, input().split()))
loadJ = []
loadJFull = []
count = 0
for i in range(M):
    temp = list(map(int, input().split()))
    loadJ.append(temp)
    for i2 in temp:
        loadJFull.append(i2)

for i,value in enumerate(H):
    status = True
    if (i in loadJFull) == False:
        count += 1
        continue
    for aLoad in loadJ:
        if (aLoad[0] == i and i <= H[aLoad[1] - 1]) or (aLoad[1] == i and i <= H[aLoad[0] - 1]):
            status = False
    if status == True:
        count += 1
print(count)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
a=[int(i) for i in input().split()]
s=0
b=[]
co=[]
for i in range(n):
  co.append([0 for iii in range(n)])
for i in range(n):
  b.append([0,0])
for i in range(m):
    p1,p2=map(int,input().split())
    if co[p1-1][p2-1]==0:
        co[p1-1][p2-1]=1
        co[p2-1][p1-1]=1
        b[p1-1][0]+=1
        b[p2-1][0]+=1
        if a[p1-1]>a[p2-1]:
            b[p1-1][1]+=1
        elif a[p1-1]<a[p2-1]:
            b[p2-1][1]+=1

for i in b:
  if i[0]==i[1]:

      s+=1
print(b)
print(s)

Submission status: Wrong Answer

Solution code:
x = input().split()
n = int(x[0])
m = int(x[1])
h = input().split()
z = [input().split() for i in range(m)]
count = []
for i in z:
  if h[int(i[0])-1] > h[int(i[1])-1]:
    count.append(i[0])
  elif h[int(i[0])-1] < h[int(i[1])-1]:
    count.append(i[1])
l = []
for i in z:
  l.extend(i)
l = set(l)
lc = []
for i in range(1, n+1):
  if (str(i) in l) == False:
    lc.append(i)
lc.extend(count)
print(len(set(lc)))

Submission status: Wrong Answer

Solution code:
a = list(map(int,input().split()))
n = a[0]
m = a[1]

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

mem = list(range(1,n+1))

for i in range(m):
  ab = list(map(int,input().split()))
  
  if h[ab[0]-1]>h[ab[1]-1]:
    if ab[1] in mem:
      mem.remove(ab[1])
      
  elif h[ab[0]-1]<h[ab[1]-1]:
    if ab[0] in mem:    
      mem.remove(ab[0])
  else:
    if ab[0] in mem:
      mem.remove(ab[0])
    elif ab[1] in mem:
      mem.remove(ab[1])
      
print(mem)
print(len(mem))

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

ans=[0]*n

count =[[h[i]] for i in range(n)]
#print(count) 
for i in range(m):
    count[ab[i][0]-1].append(h[ab[i][1]-1])
    count[ab[i][1]-1].append(h[ab[i][0]-1])
#print(count)
ans=[]
for i in range(n):
    if h[i]==max(count[i]) and count[i].count(h[i])==1:
        ans.append(max(count[i]))
#print(ans)
print(len(set(ans)))

Submission status: Wrong Answer

Solution code:
n,m=map(int, input().split())
h=list(map(int, input().split()))
dic = {}
ng = set()
chk = set()

for i in range(m):
  a,b=map(int, input().split())
  chk.add(a)
  chk.add(b)
  if h[a-1] == h[b-1]:
    if str(b) in dic:
      dic.pop(str(b))
    if str(a) in dic:
      dic.pop(str(a))
  elif h[a-1] > h[b-1]:
    if not a in ng:
      dic[str(a)] = h[a-1]
    ng.add(b)
    if str(b) in dic:
      dic.pop(str(b))
  else:
    if not b in ng:
      dic[str(b)] = h[b-1]
    ng.add(a)
    if str(a) in dic:
      dic.pop(str(a))
    
print(len(dic) + (n-len(chk)))

Submission status: Wrong Answer

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

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

count =0
P = AB
m = M
for i in range(N):
    flag = 1
    j = 0
    while j < m:
        if i+1 in P[j]:
            if i+1 == P[j][0]:
                k = 1
            else:
                k = 0

            if H[i] <= H[P[j][k]-1]:
                flag = 0
                P.pop(j)
                m -= 1
        j += 1
    if flag == 1:
        count += 1
print(count)

Submission status: Wrong Answer

Solution code:
n,k=[int(x) for x in input().split()]
obs=[int(x) for x in input().split()]
ans=[]
fake=[]
for i in range(0,k):
    a,b=[int(x) for x in input().split()]
    fake.append(a)
    fake.append(b)
    if b>a:
        ans.append(b)
    if a>b:
        if b in ans:
            ans.pop(ans.index(b))
for j in obs:
    if j not in fake:
        ans.append(j)
      
print(len(set(ans)))

Submission status: Wrong Answer

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

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)]
result = {i + 1 for i in range(n)}

for a, b in ab:
    if h[a-1] < h[b-1]:
        result.discard(a)
    else:
        result.discard(b)

print(len(result))

Submission status: Wrong Answer

Solution code:

n,m = map(int,input().split())
elevations = [ int(x) for x in input().split()]
adj_list = [ [] for x in range(n)]
repeated=[ False for x in range(n)]

for _ in range(m):
  a,b = [ int(x)-1 for x in input().split()]
  if(b in adj_list[a]):
    repeated[a]=True
    repeated[b]=True
  else:
    adj_list[a].append(b)
    adj_list[b].append(a)
    
count=0
for i,neighbours in enumerate(adj_list):
  if(not repeated[i]):
    for neighbour in neighbours:
      if(elevations[i]<=elevations[neighbour]):
        break
    else: 
      count+=1
      
print(count)

Submission status: Wrong Answer

Solution code:
N, K = map(int,input().split())
H = list(map(int,input().split()))
s = {}
for j in range(K):
  A, B = map(int,input().split())
  if H[A-1] < H[B-1]:
    s[A] = False
    s[B] = True
  elif H[A-1] == H[B-1]:
    s[A] = False
    s[B] = False
  else:
    s[A] = True
    s[B] = False
    
cnt = 0
for i in range(N):
  if not i+1 in s.keys():
    cnt+=1
    continue
  
  if s[i+1]:
    cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
H=list(map(int,input().split()))
graph=[[0]*n]*n
for i in range(m):
    a,b=map(int,input().split())
    graph[a-1][b-1]=H[b-1]
    graph[b-1][a-1]=H[a-1]
x=0
for i in range(n):
    h=H[i]
    for j in range(n):
        if h<j:
            continue
    x+=1
print(x//2)

Submission status: Wrong Answer

Solution code:
import sys
import math
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix
import itertools
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
H = LIST()

L = []

for i in range(M):
    a, b = MAP()
    L.append([a, b])

flag = [1] * N

for i, j in L:
    if H[i-1] < H[j-1]:
        flag[i-1] = 0
    elif H[i-1] > H[j-1]:
        flag[j-1] = 0
    elif H[i-1] == H[j-1]:
        flag[i-1] = 0
        flag[j-1] = 0

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

Submission status: Wrong Answer

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

print(len(h))

Submission status: Wrong Answer

Solution code:
def peaks(lookup, hs, n):
    ans = 0
    for k in lookup.keys():
        for kk in lookup[k]:
            if hs[k-1] < hs[kk-1]:
                ans -= 1
                break
        ans += 1
    print(ans + n - len(lookup.keys()))

if __name__ == "__main__":
    import sys
    from collections import defaultdict as DD
    lookup = DD(dict)
    n, m = [int(_) for _ in input().split()]
    hs = [int(_) for _ in input().split()]
    for i in range(m):
        a, b = [int(_) for _ in input().split()]
        lookup[a][b] = lookup[b][a] = True
    peaks(lookup, hs, n)

Submission status: Wrong Answer

Solution code:
#C問題
N,M = map(int, input().split())
H = input().split()
result = [True] * N
H_i = [int(s) for s in H]
bothCount = 0
for i in range(M):
    A,B = map(int, input().split())
    if(H_i[A-1] > H_i[B-1]):
        #AがBよりも高かったらAがいい展望台
        if(result[B-1] == True):
            result[B-1] = False
        result[A-1] = True
    elif(H_i[A-1] < H_i[B-1]):
        if(result[A-1] == True):
            result[A-1] = False
        result[B-1] = True
    else:
        result[A-1] = False
        result[B-1] = False
Count = 0
Count = result.count(True)
print(Count)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
h = [int(_) for _ in input().split()]
l=['']*n
for x in range(m):
    a,b = map(int, input().split())
    if h[a - 1] > h[b - 1]:
        l[a - 1] = 'good'
    else:
        l[b - 1] = 'good'
print(l.count('good'))