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:
n,m=map(int,input().split())
h=list(map(int,input().split()))
ab=[]
for i in range(m):
    ab.append(list(map(int,input().split())))
lis=[]
for i in range(m):
    lis.append(i+1)

for i in range(m):
    a=h[ab[i][0]-1]
    b=h[ab[i][1]-1]

    if a==b:
        if ab[i][0]-1 in lis:
            lis.remove(ab[i][0]-1)
        if ab[i][1]-1 in lis:
            lis.remove(ab[i][1]-1)
    if a>b:
        if ab[i][1]-1 in lis:
            lis.remove(ab[i][1]-1)
    else:
        if ab[i][0]-1 in lis:
            lis.remove(ab[i][0]-1)

print(len(lis))

Submission status: Wrong Answer

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

for i in range(n):
  h[i] = int(h[i])
#
#print(h)

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

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

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
heights=list(map(int,input().split()))
heights_w=sorted([(h,i+1) for i,h in enumerate(heights)])[::-1]
cons={i+1:set() for i in range(n)}
for _ in range(m):
  a,b=map(int,input().split())
  cons[a].add(b)
  cons[b].add(a)

watched=set()
res=0
#res_m=set()
for h,i in heights_w:
  if i in watched:
    continue
  watched.add(i)
  flg=True
  for con in cons[i]:
    flg=(flg and h<heights[con-1])
    watched.add(con)
  if flg:
    #res_m.add(i)
    res+=1
print(res)

Submission status: Wrong Answer

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

for i in range(M):
  A, B = map(int, input().split())
  clist.append(A-1)
  clist.append(B-1)
  if H[A-1] > H[B-1] and H[A-1] not in hlist:
    hlist.append(H[A-1])
  elif H[A-1] < H[B-1] and H[B-1] not in hlist:
    hlist.append(H[B-1])
"""
print(H)
print(list(set(hlist)))
print(list(set(clist)))
"""
#ans = len(list(set(hlist))) + (len(H) - len(list(set(clist))))
print(len(list(set(hlist))) + (len(H) - len(list(set(clist)))))

Submission status: Wrong Answer

Solution code:
import collections
import sys
input = lambda: sys.stdin.readline().strip()

def main():
    N,M = map(int,input().split())
    H_list = sorted(list(map(int,input().split())))
    ab_list = [map(int,input().split()) for _ in range(M)]

    min_set = set()
    for a,b in ab_list:
        min_set.add(min(a,b))
    c = collections.Counter(H_list)

    ans = 0
    for i in min_set:
        ans += c[i]
    print(ans)

main()

Submission status: Wrong Answer

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

G = [[] for i in range(N)]

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

ans = 0

for i in range(N):
    self_h = H[i]

    self_max_flag = True

    for to in range(len(G[i])):
        if (self_h <= H[to]):
            self_max_flag = False
        
    if (self_max_flag):
        ans += 1


print(ans)

Submission status: Wrong Answer

Solution code:
n,m=input().split()
n=int(n)
m=int(m)
y=([1]*n)
x=list(input().split())

for i in range(m):
    y1,y2=input().split()
    y1=int(y1)
    y2=int(y2)
    if x[y1-1]>x[y2-1]:
        y[y2-1]=0
    elif x[y1-1]<x[y2-1]:
        y[y1-1]=0
    else:
        y[y2-1]=0
        y[y1-1]=0
print(n-y.count(0))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
heights = list(map(int, input().split()))
highest = [True for _ in range(N)]
for m in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    val_a = heights[a]
    val_b = heights[b]
    # print("a= {} b= {}".format(a,b))
    # print("vala= {} valb= {}".format(val_a,val_b))
    if val_a == val_b:
        highest[a] = False
        highest[b] = False
    elif val_a > val_b:
        highest[b] = False
    elif val_a < val_b:
        highest[a] = False
    highest[0] = False
    
print(sum(highest))

Submission status: Wrong Answer

Solution code:
import numpy as np
n,m = map(int, input().split())
h = input().split() # list
for i in range(n):
    h[i] = int(h[i])
bridge = np.zeros((m,2), dtype="int")
for i in range(m):
    a,b = map(int, input().split())
    bridge[i,0] = int(a)
    bridge[i,1] = int(b)

good = [1]*n
for i in range(m):
    if h[bridge[i,0]-1] > h[bridge[i,1]-1]:
        good[bridge[i,1]-1] = 0
    elif h[bridge[i,0]-1] < h[bridge[i,1]-1]:
        good[bridge[i,0]-1] = 0
    else :
        if good[bridge[i,0]-1] == 1 and good[bridge[i,1]-1] == 1:
            pass
        elif good[bridge[i,0]-1] == 0 or good[bridge[i,1]-1] == 0:
            good[bridge[i,0]-1] = 0
            good[bridge[i,1]-1] = 0
print(sum(good))

Submission status: Wrong Answer

Solution code:
def resolve():
    # 整数 1 つ
    # n = int(input())
    # 整数複数個
    n, m = list(map(int, input().split()))
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    H = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    R = [list(map(int, input().split())) for i in range(m)]

    cnt = 0

    for i in (1, n+1):
        highst = True
        for r in R:
            if r[0] == i:
                if H[i-1] <= H[r[1]-1]:
                    highst = False
            if r[1] == i:
                if H[i-1] <= H[r[0]-1]:
                    highst = False

        if highst == True:
            cnt += 1

    print(cnt)


resolve()

Submission status: Wrong Answer

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

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

D=set(d)

for j in range(1,N+1):
  if j not in D:
    c.append(j)
    
print(len(set(c)))

Submission status: Wrong Answer

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

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

print(ans.count(0))

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
l = list(map(int,input().split()))
d = {}
for i in range(m):
	sou,des = map(int,input().split())
	if sou not in d:
		d[sou] = [des]
	else:
		d[sou].append(des)
	if des not in d:
		d[des] = [sou]
	else:
		d[des].append(sou)
#print(d)
#print(dic)
count = 0
for i in d:
	flag = True
	for j in d[i]:
		if l[i-1] < l[j-1]:
			flag = False
			break
	if flag:
		count += 1
print(count)

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)]
goodt = [1] * n
for i in range(m):
  if h[ab[i][0]-1] < h[ab[i][1]-1]:
    goodt[ab[i][0]-1] = 0
  elif h[ab[i][0]-1] >= h[ab[i][1]-1]:
    goodt[ab[i][1]-1] = 0
print(sum(goodt))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline


def main():
    n, m = input_list()
    heights = input_list()

    paths = {}
    pp = set()
    for _ in range(m):
        a, b = input_list()
        pp.add(a)
        pp.add(b)
        a = heights[a-1]
        b = heights[b-1]

        if a > b:
            if a in paths:
                paths[a].append(b)
            else:
                paths[a] = [b]
        if b > a:
            if b in paths:
                paths[b].append(a)
            else:
                paths[b] = [a]
    only_ones = n - len(pp)
    print(len(paths) + only_ones)

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

isgood = [0 for _ in range(n)]
connection = [0 for _ in range(n)]


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

    elif h[b] < h[a]:
        isgood[a] = 1
        isgood[b] = 0

    connection[a] = 1
    connection[b] = 1

ans = 0

noc = connection.count(0)

print(noc + sum(isgood))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

def input_from_console():
    n, m = map(int, input().split())
    ab_list = []
    h_list = map(int, input().split())
    for i in range(m):
        a,b = map(int, input().split())
        ab_list.append((a, b))
    return n, m, list(h_list), list(ab_list)


def solve(n, m, h_list, ab_list):
    good_observatory = [True] * n
    good_observatory[0] = False
    for (a, b) in ab_list:
        if h_list[a-1] < h_list[b-1]:
            good_observatory[a - 1] = False
        else:
            good_observatory[b - 1] = False
    return sum(good_observatory)


def main():
    n, m, h_list, ab_list = input_from_console()
    print(solve(n, m, h_list, ab_list))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()

Submission status: Wrong Answer

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

count = 0
for _ in range(M):
    A, B = map(int, input().split())
    if min(Height[A - 1], Height[B - 1]) != 0:
        count += 1
    Height[A - 1], Height[B - 1] = 0, 0

for i in Height:
    if i != 0:
        count += 1

print(count)

Submission status: Wrong Answer

Solution code:


def main():
    NM = list(map(int,input().split()))
    H = list(map(int,input().split()))

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

    Judge = [True] * NM[0]

    for i in range(NM[1]):
        ABi = list(map(int,input().split()))

        if H[ABi[0]-1] > H[ABi[1]-1]:
            Judge[ABi[0]-1] = True
            Judge[ABi[1]-1] = False

        elif H[ABi[0]-1] == H[ABi[1]-1]:
            Judge[ABi[0] - 1] = False
            Judge[ABi[1] - 1] = False

        else:
            Judge[ABi[0] - 1] = False
            Judge[ABi[1] - 1] = True

    # print(Judge)
    print(Judge.count(True))











if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
H=list(map(int,input().split()))
good=[True]*N
for i in range(M):
    A,B=map(int,input().split())
    if H[A-1]>H[B-1]:
        print("A")
        good[B-1]=False
    elif H[B-1]>H[A-1]:
        good[A-1]=False
    else:
        good[A-1],good[B-1]=False,False
ans=0
for i in good:
    if i==True:
        ans+=1
print(good)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
H = list(map(int, input().split()))
ans = [] #展望台No
for i in range(M):
    ai, bi = map(int, input().split())
    if H[ai-1] < H[bi-1]:
        ans.append(bi)
    else:
        ans.append(ai)

d = {}
for num in ans:
    if num not in d:
        d[num] = 1
    else:
        d[num]+=1

print(len(d))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
n, m = map(int, input().split())
h = list(map(int, input().split()))
ans = []
for _ in range(m):
    a, b = map(int, input().split())
    if h[a-1] >= h[b-1]:
        ans.append(b-1)
    else:
        ans.append(a-1)
print(len(set(ans)))

Submission status: Wrong Answer

Solution code:
import numpy as np
import math
n, m = map(int,input().split())
h = list(map(int,input().split()))
r = [[] for i in range(n+1)]
for i in range(m):
    a,b = map(int,input().split())
    if not b in r[a]:
        r[a].append(b)
        r[b].append(a)


num = 0
g = []

for i in range(1,n+1):
    max = -1
    mi = -1
    for j in range(len(r[i])):
        if r[i][j] > max:
            max = r[i][j]
            mi = j
        elif max == r[i][j]:
            break
        if r[i][j] == r[i][-1] and (not j in g):
            g.append(j)

print(len(g))

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

Solution code:
N,M = map(int, input().split())
H = list(map(int, input().split()))
loadJ = []
count = 0
for i in range(M):
    loadJ.append(list(map(int, input().split())))
for i,value in enumerate(H):
    status = True
    for aLoad in loadJ:
        if aLoad[0] == i:
            if i <= H[aLoad[1] - 1]:
                status = False
        elif aLoad[1] == i:
            if i <= H[aLoad[0] - 1]:
                status = False
        else:
            pass
    if status == True:
        count += 1
print(count)

Submission status: Wrong Answer

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

h_list = [int(x) for x in input().split()]
bad_set = set()

for i in range(m):
  a,b = map(int,input().split())
  if h_list[a-1] >= h_list[b-1]:
    bad_set.add(b)
  elif h_list[a-1] <= h_list[b-1]:
    bad_set.add(a)
    
print(n-len(bad_set))

Submission status: Wrong Answer

Solution code:
import sys

N, M = map(int, sys.stdin.readline().split())
H = list(map(int, sys.stdin.readline().split()))

roads = [0] + [[H[i]] for i in range(N)]

for _ in range(M):
    i, j = map(int, sys.stdin.readline().split())
    roads[i].append(j)
    roads[j].append(i)

ans = 0
for i in range(1,N+1):
    for j in range(1, len(roads[i])):
        if roads[i][j] > roads[i][0]:
            break
        
        if j == len(roads[i])-1:
            ans += 1
        
            
print(ans)

Submission status: Wrong Answer

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

G = [[] for i in range(N)]

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

ans = 0

for i in range(N):
    self_h = H[i]

    self_max_flag = True

    for to in range(len(G[i])):
        if (self_h <= H[to+1]):
            self_max_flag = False
        
    if (self_max_flag):
        ans += 1


print(ans)

Submission status: Wrong Answer

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

main()

Submission status: Wrong Answer

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


memo = H[::]
ans = 0


for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    saidai = max(memo[a], memo[b])
    memo[a] = saidai
    memo[b] = saidai
for i in range(n):
    if memo[i] == H[i]:
        ans += 1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
H = list(map(int,input().split()))
d = {}
for _ in range(M):
    ab = list(map(int,input().split()))
    if ab[0] in d.keys():
        d[ab[0]].append(ab[1])
    else:
        d[ab[0]] = [ab[1]]
    if ab[1] in d.keys():
        d[ab[1]].append(ab[0])
    else:
        d[ab[1]] = [ab[0]]

count = 0
for i in d.keys():
    for j in list(set(d[i])):
        if H[i-1] < H[j-1]:
            break
    else:
        count += 1

print(count)

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
H = list(map(int, input().split()))
import collections
d = collections.defaultdict(list)
for i in range(m):
    a,b = map(int, input().split())
    d[a].append(b-1)
    d[b].append(a-1)
ans = 0
for i in range(n):
    s = list(set(d[i]))
    #print('s',s)
    if len(s) == 0:
        ans += 1
        #print('0000000')
        continue
    f = 0
    for j in range(len(s)):
        if H[s[j]] > H[i]:
            f += 1
            continue
    if f == 0:
        ans += 1
print(ans)
#print(d)

Submission status: Wrong Answer

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

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)]
d=[ [] for i in range(n+1)]
for i in range(m):
  #a=ab[i][0]
  #b=ab[i][1]
  d[ab[i][0]].append(h[ab[i][1]-1])
  d[ab[i][1]].append(h[ab[i][0]-1])
count=0
d.pop(0)
for i in range(0,len(d)):
  if len(d[i])==0:
    count+=1
  elif h[i]<max(d[i]):
    count+=1
print(count)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
H = list(map(int, input().split()))
l = []
for i in range(M):
    A, B = map(int, input().split())
    if A < B:
        l.append(A)
    else:
        l.append(B)
ans = set(H) - set(l)
print(len(ans))

Submission status: Wrong Answer

Solution code:
s = input()

N = int(s.split()[0])
M = int(s.split()[1])

H = input().split()

tenbo = []
for i in range(N):
  tenbo.append(i+1)

for i in range(M):
  road = input().split()
  A = int(road[0])
  B = int(road[1])
  HA = int(H[A-1])
  HB = int(H[B-1])
  if HA >= HB and B in tenbo:
    tenbo.remove(B)
  elif HA <= HB and A in tenbo:
    tenbo.remove(A)
    
print(len(tenbo))

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]:
        continue
    if l[a-1] == l[b-1]:
        tmp[a-1]=-1
        tmp[b-1]=-1
    else:
        t=a
        a=b
        b=t
    if tmp[a-1]!= -1:
        tmp[a-1] += 1
    tmp[b-1]=-1

cnt=0
for i in range(len(tmp)):
    if tmp[i] >= 0:
        cnt +=1
print(cnt)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
h=[0]+list(map(int,input().split()))
a=[None]*m
b=[None]*m
for i in range(m):
    a[i],b[i]=map(int,input().split())
t = [False]+[True]*n

for i in range(m):
    if a[i] == b[i]:
        t[a[i]]=False
        t[b[i]]=False
        continue
    if h[a[i]] > h[b[i]]:
        t[b[i]] = False
    else:
        t[a[i]] = False
print(t.count(True))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
h = list(map(int, input().split()))
l = [0]*n
good = []
count = 0
for _ in range(m):
    a, b = map(int, input().split())
    l[a-1] += 1
    l[b-1] += 1
    if (h[a-1] > h[b-1]) and (b not in good):
        good.append(b)
        count += 1
    elif h[a-1] < h[b-1] and (a not in good):
        good.append(a)
        count += 1
count += l.count(0)
print(count)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
import numpy as np

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

T_Height = [int(h) for h in input().split()]

Roads = [[0] * n for _ in range(n)]

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


i = 0
ans = 0
for E in Roads:
    print(max(E), T_Height[i])
    if T_Height[i] > max(E):
        ans += 1
    i+=1

print(ans)

Submission status: Wrong Answer

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

flag = [True] * n
for _ in range(m):
    a, b = map(int, input().split())
    if h[a-1] >= h[b-1]:
        flag[b-1] = False
    elif h[b-1] > h[a-1]:
        flag[a-1] = False


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

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
hlst = list(map(int, input().split()))
lst = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    lst[a].append(hlst[b]-1)
    lst[b].append(hlst[a]-1)
i = 0

for _ in range(n):
  if sum([o for o in lst[_] if o > _]) == 0:
    i += 1
print(i)

Submission status: Wrong Answer

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

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

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

ans = 0
minus = 0
# print(graph)

for i in range(n):
    height = h[i]
    if graph[i]:
        flg = True
        for j in graph[i]:
            if i == j:
                continue
            if h[j] > height:
                flg = False
                minus += 1
                break
        if flg is True:
            ans += 1
    else:
        ans += 1
        minus += 1
        continue

print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    N, M = map(int, input().split())
    HN = list(map(int, input().split()))

    temp = [True for _ in range(N)]
    for _ in range(M):
        A, B = map(int, input().split())

        if HN[A - 1] < HN[B - 1]:
            temp[A - 1] = False
        if HN[B - 1] < HN[A - 1]:
            temp[B - 1] = False
        else:
            temp[A - 1] = False
            temp[B - 1] = False

    print(sum([1 for a in temp if a]))


main()

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
h=list(map(int,input().split()))
l=[[] for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  l[a-1].append(b)
  l[b-1].append(a)
ans=0
print(l)
for i in l:
  p=True
  for j in i:
    if h[l.index(i)]<=h[j-1]:
      p=False
      break
  if p:
    ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
import copy
n,m=map(int,input().split())
h=list(map(int,input().split()))
d={}
for i, x in enumerate(h):
    if d.get(x):
        d[x].append(i+1)
    else:
        d[x] = [i+1]
m_ = max(d.keys())
num=0
l=copy.copy(d[m_])
for _ in range(m):
    x = list(map(int, input().split()))
    if x[0] in d[m_]:
        l.append(x[1])
    elif x[1] in d[m_]:
        l.append(x[0])
print(len(list(set(l))))

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
h = list(map(int,input().split()))
route = []
lower = []
cnt = 0
for i in range (m):
    s = list(map(int,input().split()))
    route.append(s)
for i in range(len(route)):
    if h[route[i][0]-1]>=h[route[i][1]-1]:
        lower.append(route[i][1])
    elif h[route[i][1]-1]>=h[route[i][0]-1]:
        lower.append(route[i][0])
for i in range(1,n+1):
    if i not in lower:
        cnt += 1
print(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

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

Submission status: Wrong Answer

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

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

print(G.count(0))

Submission status: Wrong Answer

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

l=[]
for a in [int(i) for i in input().split()]:
  l.append(a)

ans_list=[1]*n  
  
for _ in range(m):
  a,b=(map(int,input().split()))
  if l[a-1]<l[b-1]:
    ans_list[a-1]=0
  else:
    ans_list[b-1]=0
  
#print(ans_list)
print(sum(ans_list))

Submission status: Wrong Answer

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

observatory_list = []

for _ in range(m):
    a, b = map(int, input().split())
    for observatory in observatory_list:
        if a in observatory or b in observatory:
            observatory != {a, b}
    else:
        observatory_list.append({a, b})

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:
n,m = map(int,input().split())
h = list(map(int,input().split()))
ans = 0
ls = [0]*n
for i in range(m):
    a,b = map(int,input().split())
    ls[a-1] += 1
    ls[b-1] += 1
    
for i in ls:
    if i >= 2:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
# cook your code here
n,m=map(int,raw_input().split())
a=map(int,raw_input().split())
d={}
a=[0]+a

for i in range(m):
    p,q=map(int,raw_input().split())
    
    if p not in d:
    	d[p]=[a[q]]
    	
    else:
       
        d[p]+=[a[q]]

	if q not in d:
		d[q]=[a[p]]
	else:
		d[q]+=[a[p]]
    
    


c=0
#print d
for i in range(1,n+1):
	if i in d:
		if a[i]>max(d[i]):
			c+=1
	
	else:
		c+=1

print c

Submission status: Wrong Answer

Solution code:
from sys import stdin
from sys import setrecursionlimit
from queue import deque

setrecursionlimit(10 ** 7)

n,m = map(int,stdin.readline().rstrip().split())
h = list(map(int,stdin.readline().rstrip().split()))
li = [[]for _ in range(n)]
lim = [h[i] for i in range(n)]
for i in range(m):
    a,b = map(int,stdin.readline().rstrip().split())
    a -= 1
    b -= 1
    li[a].append(b)
    li[b].append(a)

work_queue = deque([])
visited = [False]*n
point = 1

for num in range(n):
    work_queue.append(0)
    if visited[num] == True:
        continue
    else:
        visited[num] = True
        point += 1
    while work_queue:
        now = work_queue.popleft()
        visited[now] = True
        for i in li[now]:
            if visited[i]:
                continue
            work_queue.append(i)
            visited[i] = True
print(point)

Submission status: Wrong Answer

Solution code:
def io():
    return map(int,input().split())
def op():
    return list(map(int,input().split()))
n,k=io()
l=op()
c=0
s=set()
s1=set()
for _ in range(k):
    a,b=io()
    s1.update((a,b))
    a-=1
    b-=1
    if l[a]>l[b]:
        s.add(a)
        if l[b] in s:
            s.remove(l[b])
    elif l[a]<l[b]:
        s.add(b)
        if l[b] in s:
            s.remove(l[b])
c+=n-len(s1)
print(len(s)+c)

Submission status: Wrong Answer

Solution code:
n,m=list(map(int, input().split()))
dic={}
h=list(map(int, input().split()))
for i in range(m):
  a,b=list(map(int, input().split()))
  a-=1
  b-=1
  
  if h[a]>h[b]:
    dic[a]=True
    dic[b]=False
  if h[b]>h[a]:
    dic[b]=True 
    dic[a]=False
  if h[b]==h[a]:
    dic[b]=False
    dic[a]=False
  #print(dic)
ct=0
for i in range(n):
  if i not in dic:
    ct+=1
print(list(dic.values()).count(True)+ct)

Submission status: Wrong Answer

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


result = [1 for _ in range(n)]
for _ in range(m):
    a, b = list(map(int, input().split()))
    if h[a-1] < h[b-1]:
        result[b-1] = 1
        result[a-1] = 0
    elif h[a-1] < h[b-1]:
        result[b-1] = 0
        result[a-1] = 1
    else:
        result[b-1] = 0
        result[a-1] = 0
    
print(result.count(1))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N, M =  input().strip().split()
N = int(N)
M = int(M)
obs = [int(h) for h in input().split()]
edges = {}
for _ in range(M):
    a, b =  input().split()
    a, b = int(a), int(b)
    if a not in edges:
        edges[a] = [b]
    else:
        edges[a].append(b)
    if b not in edges:
        edges[b] = [a]
    else:
        edges[b].append(a)
num_good = 0
for i in range(1,N+1):
    if i not in edges:
        num_good += 1
    else:
        isGood = 1
        for neighbour in edges[i]:
            if obs[neighbour-1] >= obs[i-1] or edges[i].count(neighbour)>1:
                isGood = 0
                break
        num_good += isGood
print(num_good)

Submission status: Wrong Answer

Solution code:
import numpy as np
import math
n, m = map(int,input().split())
h = list(map(int,input().split()))
r = [[] for i in range(n+1)]
for i in range(m):
    a,b = map(int,input().split())
    r[a].append(b)
    r[b].append(a)


num = 0
g = []

for i in range(1,n+1):
    max = -1
    mi = -1
    for j in range(len(r[i])):
        if r[i][j] > max:
            max = r[i][j]
            mi = j
        elif max == r[i][j]:
            break
        if r[i][j] == r[i][-1] and (not j in g):
            g.append(j)

print(len(g))

Submission status: Wrong Answer

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

ans=[1]*n
for a,b in ab:
    if hs[a-1]>=hs[b-1]:
        ans[b-1]=0
    elif hs[a-1]<hs[b-1]:
        ans[a-1]=0
print(sum(ans))

Submission status: Wrong Answer

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

ANS=[1]*N
path=[]

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

print(sum(ANS))