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

check = [True] * n #小さかったらfalseに
for i in range(m):
    print(i)
    a,b = (map(int,input().split()))
    if h[a-1] > h[b-1]:
        check[b-1] = False
    elif h[a-1] < h[b-1]:
       # print("i,check",i,check)
        check[a-1] = False
    else:
        check[a-1] = False
        check[b-1] = False
print(sum(check))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

ans_list = []
for i in range(n):
  tmp = 0
  if list[i][1] == []:
    tmp = 1
  else:
    for j in range(len(list[i][1])):
      if h[list[i][0]] > h[list[i][1][j]]:
        tmp = 1
  ans_list.append(tmp)

print(str(sum(ans_list)))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

n,m = map(int,input().split())
li = []
temp = input().split()
for i in range(n):
    temp1 = [int(temp[i]), True]
    li.append(temp1)
    
for i in range(m):
    temp2 = input().split()
    a = int(temp2[0])
    b = int(temp2[1])
    
    if li[a-1][0] < li[b-1][0]:
        li[a-1][1] = False
    elif li[a-1][0] > li[b-1][0]:
        li[b-1][1] = False
    else :
        li[a-1][1] = li[b-1][1] = False
cnt = 0
for elem in li:
    if elem[1] == False:
        cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
co = list(map(int,input().split()))
N = co[0]
M = co[1]
h = list(map(int,input().split()))
tenbo = [0 for i in range(N)]
for i in range(M):
    load = list(map(int,input().split()))
    if h[load[0]-1] >= h[load[1]-1]:
        tenbo[load[1]-1] +=1
    elif  h[load[0]-1] <= h[load[1]-1]:
        tenbo[load[0]-1] +=1
ans =0
for i in range(N):
    if tenbo[i] == 0:
        ans +=1
print(ans)

Submission status: Wrong Answer

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

n,m = map(int,input().split())
H = list(map(int,input().split()))
List = [list(map(int, input().split())) for i in range(m)]
 
num = 0
x = 1
while x <= n:
    y=0
    for a,b in List:
        if a == x:
            if H[a-1] < H[b-1]:
                break
            else:
                y+=1
        elif b==x:
            if H[b-1] < H[a-1]:
                break
            else:
                y+=1
    if y>0:
        num +=1
    x+=1
 
print(num)

Submission status: Wrong Answer

Solution code:
import sys
def main():
    # scan(展望台の数N, 道の数M)
    N,M = map(int, input().split())
    # 展望台の高さ
    H = list(map(int, input().split()))
    # 展望台の持つ道リスト
    obsstat = [0]*N # 展望台のstatus(自分より高いのが現れたら1になる)
    for _ in range(M):
        a1,a2 = map(int, input().split())
        if H[a1-1]<=H[a2-1]: obsstat[a1-1] = 1
        elif H[a1-1]>=H[a2-1]: obsstat[a2-1] = 1

    print(obsstat.count(0))

main()

Submission status: Wrong Answer

Solution code:
import sys
def main():
    # scan(展望台の数N, 道の数M)
    N,M = map(int, input().split())
    # 展望台の高さ
    H = list(map(int, input().split()))
    # 展望台の持つ道リスト
    obsstat = [0]*N # 展望台のstatus(自分より高いのが現れたら1になる)
    for _ in range(M):
        a1,a2 = map(int, input().split())
        if H[a1-1]<H[a2-1]: obsstat[a1-1] = 1
        elif H[a1-1]>H[a2-1]: obsstat[a2-1] = 1

    print(obsstat.count(0))

main()

Submission status: Wrong Answer

Solution code:
import sys
def main():
    # scan(展望台の数N, 道の数M)
    N,M = map(int, input().split())
    # 展望台の高さ
    H = list(map(int, input().split()))
    # 展望台の持つ道リスト
    obsstat = [0]*N # 展望台のstatus(自分より高いのが現れたら1になる)
    for _ in range(M):
        a1,a2 = map(int, input().split())
        if H[a1-1]<H[a2-1]: obsstat[a1-1] = 1
        else: obsstat[a2-1] = 1

    print(obsstat.count(0))

main()

Submission status: Wrong Answer

Solution code:
import sys
def main():
    # scan(展望台の数N, 道の数M)
    N,M = map(int, input().split())
    # 展望台の高さ
    H = list(map(int, input().split()))
    # 展望台の持つ道リスト 4つのうち1->2,3ならば road[0]=[0,1,1,0] *x-1が1となるのに注意
    road = [[0]*N for _ in range(N)]
    for _ in range(M):
        a1,a2 = map(int, input().split())
        if H[a1-1]<H[a2-1]: road[a1-1][a2-1] = 1
        else: road[a2-1][a1-1] = 1

    # 繋がる展望台のうち自分が一番高い or 他と繋がっていない 展望台の数を返す
    goodobs = 0
    for i in range(N):
        if 1 not in road[i]:
            goodobs+=1
    print(goodobs)

main()

Submission status: Wrong Answer

Solution code:
import itertools
N, M = map(int, input().split())
H = list(map(int, input().split()))
bridge = [list(map(int, input().split())) for _ in range(M)]
ans = []
for b in bridge:
    if H[b[0]-1] < H[b[1]-1] and b[1] not in ans:
        ans.append(b[1])
        if b[0] in ans:
            ans.remove(b[0])
    elif H[b[0]-1] > H[b[1]-1] and b[0] not in ans:
        ans.append(b[0])
        if b[1] in ans:
            ans.remove(b[1])
print(len(ans)+(N-len(set(list(itertools.chain.from_iterable(bridge))))))

Submission status: Wrong Answer

Solution code:
import sys
def main():
    # scan(展望台の数N, 道の数M)
    N,M = map(int, input().split())
    # 展望台の高さ
    H = list(map(int, input().split()))
    # 展望台の持つ道リスト 4つのうち1->2,3ならば road[0]=[0,1,1,0] *x-1が1となるのに注意
    road = [[0]*N for _ in range(N)]
    for _ in range(M):
        a1,a2 = map(int, input().split())
        if H[a1-1]<H[a2-1]: road[a1-1][a2-1] = 1
        elif H[a1-1]>H[a2-1]: road[a2-1][a1-1] = 1

    # 繋がる展望台のうち自分が一番高い or 他と繋がっていない 展望台の数を返す
    goodobs = 0
    for i in range(N):
        if 1 not in road[i]:
            goodobs+=1
    print(goodobs)

main()

Submission status: Wrong Answer

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

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

print(sum(lowerlist))

Submission status: Wrong Answer

Solution code:
import sys
def main():
    # scan(展望台の数N, 道の数M)
    N,M = map(int, input().split())
    # 展望台の高さ
    H = list(map(int, input().split()))
    # 展望台の持つ道リスト 4つのうち1->2,3ならば road[0]=[0,1,1,0] *x-1が1となるのに注意
    road = [[0]*N for _ in range(N)]
    for _ in range(M):
        a1,a2 = map(int, input().split())
        road[a1-1][a2-1] = 1
        road[a2-1][a1-1] = 1
    # 繋がる展望台のうち自分が一番高い or 他と繋がっていない 展望台の数を返す
    goodobs = 0
    for i in range(N):
        if 1 not in road[i]:
            goodobs+=1
        else:
            for j in range(N):
                if road[i][j]==1 and H[i]>H[j]:
                    goodobs+=1
                    break
    print(goodobs)

main()

Submission status: Wrong Answer

Solution code:
class UnionFind:
    def __init__(self, n):
        self.parent = [i for i in range(n)]

    def root(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.root(self.parent[x])
            return self.parent[x]

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x != y:
            self.parent[x] = y

    def same(self, x, y):
        return self.root(x) == self.root(y)

N, M = map(int, input().split())
un = UnionFind(N)
H = list(map(int, input().split()))
for i in range(M):
    a, b = map(int, input().split())
    un.unite(a-1, b-1)
se = set()
for i in un.parent:
    se.add(i)
print(len(se))

Submission status: Wrong Answer

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

print(ans.count(0))

Submission status: Wrong Answer

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

print(ans.count(1))

Submission status: Wrong Answer

Solution code:
from operator import itemgetter #ex. sorted(l,key=itemgetter(0))

ii = lambda:int(input())
mi = lambda:list(map(int,input().split()))
ix = lambda x:list(input() for _ in range(x))
mix = lambda x:list(mi() for _ in range(x))
iix = lambda x:list(int(input()) for _ in range(x))
##########
def main(n,m,h,l):
    res = []
    hs = sorted(h,key=itemgetter(1),reverse=True)
    checked = {i:0 for i in range(1,n+1)}
    g = creategraph(n)
    
    for item in hs:
        existsame = 0
        p,v = item
        if checked[p] == 1 : continue
        checked[p] = 1
        for i in g[p]:
            if h[i-1][1] == v : existsame = 1
            checked[i] = 1
        if not existsame : res.append(p)
    return len(res)
    
def creategraph(n):
    g = {i:[] for i in range(1,n+1)}
    for a,b in l:
        g[a].append(b)
        g[b].append(a)
    for i in range(1,len(g)+1):
        g[i] = [x for x in set(g[i])]
    return g
    
n,m = mi()
h = list([i+1,v] for i,v in enumerate(mi()))
l = mix(m)
print(main(n,m,h,l))

Submission status: Wrong Answer

Solution code:
import numpy as np

n,m = map(int, input().split())
h = np.array(list(map(int, input().split())))

high = np.array([1]*n)
cnt = np.array([0]*n)

for _ in range(m):
    a,b = map(int, input().split())
    if h[a-1] < h[b-1]:
        high[a-1] *= 0
        
    
    elif h[a-1] > h[b-1]:
        high[b-1] *= 0

ans = np.count_nonzero(high==1)

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

n,m = map(int, input().split())
h = np.array(list(map(int, input().split())))

high = np.array([0]*n)
cnt = np.array([0]*n)

for _ in range(m):
    a,b = map(int, input().split())
    if h[a-1] < h[b-1]:
        high[a-1] -= 1
        
    
    elif h[a-1] > h[b-1]:
        high[b-1] -= 1
    cnt[a-1] += 1
    cnt[b-1] += 1

ans = np.count_nonzero(high==0) +np.count_nonzero(cnt==0)

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

n,m = map(int, input().split())
h = np.array(list(map(int, input().split())))

high = np.array([0]*n)
cnt = np.array([0]*n)

for _ in range(m):
    a,b = map(int, input().split())
    if h[a-1] > h[b-1]:
        high[a-1] -= 1
        
    
    elif h[a-1] < h[b-1]:
        high[b-1] -= 1
    cnt[a-1] += 1
    cnt[b-1] += 1

ans = np.count_nonzero(high==0) +np.count_nonzero(cnt==0)

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

n,m = map(int, input().split())
h = np.array(list(map(int, input().split())))

high = np.array([0]*n)
cnt = np.array([0]*n)

for _ in range(m):
    a,b = map(int, input().split())
    if h[a-1] > h[b-1]:
        high[a-1] += 1
    
    elif h[a-1] < h[b-1]:
        high[b-1] += 1
    cnt[a-1] += 1
    cnt[b-1] += 1

ans = np.count_nonzero(high>=1) +np.count_nonzero(cnt==0)

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

n,m = map(int, input().split())
h = np.array(list(map(int, input().split())))

high = np.array([0]*n)
cnt = np.array([0]*n)

for _ in range(m):
    a,b = map(int, input().split())
    if h[a-1] > h[b-1]:
        h[a-1] += 1
    
    elif h[a-1] < h[b-1]:
        h[b-1] += 1
    cnt[a-1] += 1
    cnt[b-1] += 1

ans = np.count_nonzero(high>=1) +np.count_nonzero(cnt==0)

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

n,m = map(int, input().split())
h = np.array(list(map(int, input().split())))

high = np.array([0]*n)
cnt = np.array([0]*n)

for _ in range(m):
    a,b = map(int, input().split())
    if h[a-1] > h[b-1]:
        h[a-1] += 1
    
    elif h[a-1] < h[b-1]:
        h[b-1] += 1
    cnt[a-1] += 1
    cnt[b-1] += 1

ans = np.count_nonzero(high==1) +np.count_nonzero(cnt==0)

print(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):
  A, B = map(int, input().split())
  if H[A - 1] <= H[B -1]:
    ans[B - 1] = 0
  elif H[A - 1] >= H[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
for i in range(M):
  A, B = map(int, input().split())
  if H[A - 1] <= H[B -1]:
    ans[B - 1] = 0
  elif H[A - 1] >= H[B - 1]:
    ans[B - 1] = 0


print(sum(ans))

Submission status: Wrong Answer

Solution code:
import numpy as np

N, M = input().split()
H = np.array(input().split())
canGoH = np.copy(H)
             
for i in range(int(M)):
    position1, position2 = input().split()
    if canGoH[int(position1)-1] > canGoH[int(position2)-1]:
        canGoH[int(position2)-1] = canGoH[int(position1)-1]
    elif canGoH[int(position2)-1] > canGoH[int(position1)-1]:
        canGoH[int(position1)-1] = canGoH[int(position2)-1]
    else:
        canGoH[int(position1)-1] = 0
        canGoH[int(position2)-1] = 0

        
print(sum(canGoH == H))

Submission status: Wrong Answer

Solution code:
import numpy as np

N, M = input().split()
H = np.array(input().split())
canGoH = np.copy(H)
             
for i in range(int(M)):
    position1, position2 = input().split()
    if H[int(position1)-1] > H[int(position2)-1]:
        canGoH[int(position2)-1] = H[int(position1)-1]
    elif H[int(position2)-1] > H[int(position1)-1]:
        canGoH[int(position1)-1] = H[int(position2)-1]
    else:
        canGoH[int(position1)-1] = 0
        canGoH[int(position2)-1] = 0
        
print(sum(canGoH == H))

Submission status: Wrong Answer

Solution code:
import numpy as np

N, M = input().split()
H = np.array(input().split())
canGoH = np.copy(H)
             
for i in range(int(M)):
    position1, position2 = input().split()
    if H[int(position1)-1] > H[int(position2)-1]:
        canGoH[int(position2)-1] = H[int(position1)-1]
    elif H[int(position2)-1] > H[int(position1)-1]:
        canGoH[int(position1)-1] = H[int(position2)-1]

        
print(sum(canGoH == H))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
H = list(map(int, input().split()))
preH =[]
for i in range(M):
    preH.append(list(map(int, input().split())))
ans = [True]*N

for i in range(M):
    A,B = preH[i]
   

    if(H[A-1]>=H[B-1]):
        ans[A-1] = False
    if(H[B-1]>=H[A-1]):
        ans[B-1] = False

print(ans.count(True))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(M):
    preH.append(list(map(int, input().split())))
ans = [True]*N

for i in range(M):
    A,B = preH[i] #一行ずつ処理

    if(H[A-1]>=H[B-1]):
        ans[A-1] = False
    if(H[B-1]>=H[A-1]):
        ans[B-1] = False

print(ans.count(True))

Submission status: Wrong Answer

Solution code:
import numpy as np

N, M = input().split()
H = np.array(input().split())
canGoH = np.copy(H)
             
for i in range(int(M)):
    position1, position2 = input().split()
    if H[int(position1)-1] > H[int(position2)-1]:
        canGoH[int(position2)-1] = H[int(position1)-1]
    else:
        canGoH[int(position1)-1] = H[int(position2)-1]

        
        
print(sum(canGoH == H))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

N, M = input().split()
H = np.array(input().split())
canGoH = np.copy(H)
             
for i in range(int(M)):
    position1, position2 = input().split()
    if H[int(position1)-1] > H[int(position2)-1]:
        canGoH[int(position2)-1] = H[int(position1)-1]
        canGoH[int(position1)-1] = 0
    else:
        canGoH[int(position1)-1] = H[int(position2)-1]
        canGoH[int(position2)-1] = 0

        
print(sum(canGoH > H))

Submission status: Wrong Answer

Solution code:
import numpy as np

N, M = input().split()
H = np.array(input().split())
canGoH = np.copy(H)
             
for i in range(int(M)):
    position1, position2 = input().split()
    if H[int(position1)-1] > H[int(position2)-1]:
        canGoH[int(position2)-1] = H[int(position1)-1]
        #canGoH[int(position1)-1] = 0
    else:
        canGoH[int(position1)-1] = H[int(position2)-1]
        #canGoH[int(position2)-1] = 0

        
print(sum(canGoH > H))

Submission status: Wrong Answer

Solution code:
import numpy as np

N, M = input().split()
H = np.array(input().split())
canGoH = np.copy(H)
             
for i in range(int(M)):
    position1, position2 = input().split()
    if H[int(position1)-1] > H[int(position2)-1]:
        canGoH[int(position2)-1] = H[int(position1)-1]
        canGoH[int(position1)-1] = 0
    else:
        canGoH[int(position1)-1] = H[int(position2)-1]
        canGoH[int(position2)-1] = 0

        
print(sum(canGoH >= H))

Submission status: Wrong Answer

Solution code:
import numpy as np

N, M = input().split()
H = np.array(input().split())
canGoH = np.copy(H)
             
for i in range(int(M)):
    position1, position2 = input().split()
    if H[int(position1)-1] >= H[int(position2)-1]:
        canGoH[int(position2)-1] = H[int(position1)-1]
        canGoH[int(position1)-1] = 0
    else:
        canGoH[int(position1)-1] = H[int(position2)-1]
        canGoH[int(position2)-1] = 0

        
print(sum(canGoH >= H))

Submission status: Wrong Answer

Solution code:
import numpy as np

N, M = input().split()
H = np.array(input().split())
canGoH = np.copy(H)
             
for i in range(int(M)):
    position1, position2 = input().split()
    if H[int(position1)-1] >= H[int(position2)-1]:
        canGoH[int(position2)-1] = H[int(position1)-1]
    else:
        canGoH[int(position1)-1] = H[int(position2)-1]

        
print(sum(canGoH > H))

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
H=list(map(int,input().split()))
max_=H.copy()
for i in range(M):
    a,b=map(lambda x:int(x)-1,input().split())
    max_[a]=max(max_[a],max_[b])
    max_[b]=max(max_[a],max_[b])
ans=0
for i in range(N):
    if(max_[i]==H[i]):
        ans+=1
print(ans)

Submission status: Wrong Answer

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

main()

Submission status: Wrong Answer

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

main()

Submission status: Wrong Answer

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


main()

Submission status: Wrong Answer

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


main()

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 i in range(M)]

B=[0]*N
# from functools import lru_cache
# @lru_cache(maxsize=1000)
# def yapoos()
for i in A:
    if H[i[0]-1]>H[i[1]-1]:
        B[i[1]-1]=1
    elif H[i[0]-1]<H[i[1]-1]:
        B[i[0]-1]=1
print(B.count(0))

Submission status: Wrong Answer

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

for i in range(m):
    a,b=map(int,input().split())
    l.append(a)
    l.append(b)
    if(h[a-1] > h[b-1]):
        temp.append(a)
    elif(h[a-1] < h[b-1]):
        temp.append(b)
        
    
    elif(h[a-1] < h[b-1] and a in set(temp)):temp.remove(a)
    
    elif(h[b-1] < h[a-1] and b in set(temp)):temp.remove(b)
    


print(len(set(temp))+len(set(a1)-set(l)))

Submission status: Wrong Answer

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

for i in range(m):
    a,b=map(int,input().split())
    l.append(a)
    l.append(b)
    if(h[a-1] > h[b-1] and a not in temp ):
        temp.append(a)
    elif(h[a-1] < h[b-1] and b not in temp):
        temp.append(b)
        
    
    elif(h[a-1] < h[b-1] and a in temp):temp.remove(a)
    
    elif(h[b-1] < h[a-1] and b in temp):temp.remove(b)
    


print(len(set(temp))+len(set(a1)-set(l)))

Submission status: Wrong Answer

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

bridge = [[] for i in range(N+1)]

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

ans = 0
count = 0

for i in range(1,N+1):
    tmp = bridge[i]
    tmp = list(set(tmp))
    flag = True
    for j in range(len(tmp)):
        if H[i-1] < H[tmp[j]-1]:
            flag = False
    if flag == False and len(bridge[i]) != 0:
        continue
    elif flag == True and len(bridge[i]) != 0:
        ans += 1
            
    if len(bridge[i]) == 0:
        ans +=1
        
print(ans)

Submission status: Wrong Answer

Solution code:
#値の入力
n,m = map(int,input().split())
h = list(map(int, input().split()))
obs = []
j = []
for i in range(m):
    a, b = list(map(int, input().split()))
    j.append([a,b])

for i in j:
    if h[i[0]-1] > h[i[1]-1]:
        obs.append(h[i[0]-1]) 
    elif h[i[1]-1] > h[i[0]-1]:
        obs.append(h[i[1]-1])
print(len(set(obs)))

Submission status: Wrong Answer

Solution code:
#値の入力
n,m = map(int,input().split())
h = list(map(int, input().split()))
obs = []
j = []
for i in range(m):
    a, b = list(map(int, input().split()))
    j.append([a,b])

for i in j:
    if h[i[0]-1] > h[i[1]-1]:
        obs.append(h[i[0]-1]) 
    elif h[i[1]-1] > h[i[0]-1]:
        obs.append(h[i[1]-1])
print(obs) 
print(len(set(obs)))

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
List=list(map(int,input().split()))#n個
s=[]

for i in range(m):
    a,b=list(map(int,input().split()))
    if List[a-1]>List[b-1]:
        s.append(b)
    elif List[a-1]<List[b-1]:
        s.append(a)
    else:
        s.append(a)
        s.append(b)
    

print(s)
t=set(s)       
print(n-len(t))

Submission status: Wrong Answer

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

for i in range(M):
  A=list(map(int, input().split()))
  Ah = H[A[0]-1]
  Bh = H[A[1]-1]
  if Ah >= Bh:
    h[A[1]-1]=0
  else:
    h[A[0]-1]=0
print(sum(h))

Submission status: Wrong Answer

Solution code:
#abc 166
#c
n,m = map(int, input().split())
ln_H = list(map(int, input().split()))
ln_pass = []
for i in range(m):
    ln_pass.append(list(map(int, input().split())))
nGood =0
for i in range(n):
    iH = ln_H[i]
    for j in ln_pass:
        if j[0] == i:
            iH = max(iH, ln_H[j[1]-1])
        elif j[1] == i:
            iH = max(iH, ln_H[j[0]-1])
    if iH == ln_H[i]:
        nGood  += 1
print(nGood)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
List=list(map(int,input().split()))#n個
s=[]

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

t=set(s)       
print(n-len(t))

Submission status: Wrong Answer

Solution code:
from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *
from sys import stdin
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
import math

def bin1(l,r,k,t,b,val,ans):
	if(l>r):
		return ans
	else:
		mid=(l+r)//2
		v=k**mid
		if(v==val):
			return v
		elif(v>val):
			ans=mid
			return bin1(mid+1,r,k,t,b,val,ans)
		else:
			return bin1(l,mid-1,k,t,b,val,ans)
		
def bin2(l,r,k,t,b,val,ans):
	if(l>r):
		return ans
	else:
		mid=(l+r)//2
		v=t*(k**mid)+b*(mid)
		if(v==val):
			return v
		elif(v>val):
			ans=mid
			return bin2(l,mid-1,k,t,b,val,ans)
		else:
			return bin2(mid+1,r,k,t,b,val,ans)

def SieveOfEratosthenes(n): 
      
    # Create a boolean array "prime[0..n]" and initialize 
    #  all entries it as true. A value in prime[i] will 
    # finally be false if i is Not a prime, else true. 
    prime = [True for i in range(n+1)] 
    p = 2
    while (p * p <= n): 
          
        # If prime[p] is not changed, then it is a prime 
        if (prime[p] == True): 
              
            # Update all multiples of p 
            for i in range(p * p, n+1, p): 
                prime[i] = False
        p += 1
    l=[]
    for i in range(2,n+1):
    	if(prime[i]):
    		l.append(i)
    return l
def bin(l,r,ll,val):
	if(l>r):
		return -1
	else:
		mid=(l+r)//2
		if(val>=ll[mid][0] and val<=ll[mid][1]):
			return mid
		elif(val<ll[mid][0]):
			return bin(l,mid-1,ll,val)
		else:
			return bin(mid+1,r,ll,val)
def deci(n):
	s=""
	while(n!=0):
		if(n%2==0):
			n=n//2
			s="0"+s
		else:
			n=n//2
			s="1"+s
	return s
def diff(s1,s2):
	if(len(s1)<len(s2)):
		v=len(s1)
		while(v!=len(s2)):
			s1="0"+s1
			v=v+1
	else:
		v=len(s2)
		while(v!=len(s1)):
			s2="0"+s2
			v=v+1
	c=0
	for i in range(len(s1)):
		if(s1[i:i+1]!=s2[i:i+1]):
			c=c+1
	return c
from sys import stdin, stdout 
def fac(a,b):
	v=a
	while(a!=b):
		v*=a-1
		a=a-1
	return v
def bino(l,r,n):
	if(l>r):
		return -1
	else:
		mid=(l+r)//2
		val1=math.log((n/mid)+1,2)
		val2=int(val1)
		if(val1==val2):
			return val1
		elif(val1<1.0):
			return bino(l,mid-1,n)
		else:
			return bino(mid+1,r,n)

def binary(l,r,ll,val,ans):
	if(l>r):
		return ans
	else:
		mid=(l+r)//2
		if(ll[mid]==val):
			return ll[mid]
		elif(ll[mid]<val):
			ans=ll[mid]
			return binary(mid+1,r,ll,val,ans)
		else:
			return binary(l,mid-1,ll,val,ans)
def check(n):
	v=1
	while(n!=0):
		if(n%10==0 or n%10==1):
			n=n//10
		else:
			v=0
			break
	return v
def stairs(n,m,val,c,l):
	if(val>n):
		return 100000
	elif(val==n):
		if(l[val]!=-1):
			return l[val]
		elif(c%m==0):
			l[val]=c
			return l[val];
		else:
			l[val]=100000
			return l[val]
	else:
		# if(l[val]!=-1):
		# 	return l[val]
		# else:
		l[val]=min(stairs(n,m,val+1,c+1,l),stairs(n,m,val+2,c+1,l))
		return l[val]

if __name__ == '__main__':
	n,m=map(int,input().split(" "))
	l=list(map(int,input().split(" ")))
	l1=[]
	for i in range(n):
		l2=[]
		l1.append(l2)
	for i in range(m):
		a,b=map(int,input().split(" "))
		l1[a-1].append(b-1)
		l1[b-1].append(a-1)

	c=0
	for i in range(n):
		if(len(l1[i])!=0 and l[i]>max(l1[i])):
			c+=1
	print(c)

Submission status: Wrong Answer

Solution code:
N,K = map(int, input().split())
H = list(map(int, input().strip().split()))
A = []
for i in range(0,K):
    array = list(map(int, input().strip().split()))
    A.append(array)
des = []
for i in range(0,K):
    if(H[A[i][0]-1] > H[A[i][1]-1]):
       des.append(H[A[i][1]-1])
    else:
        des.append(H[A[i][0]-1])
ans = sorted(set(des), key=des.index)
print(N-len(ans))