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

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

cnt = 0
res = {}
for i in range(N):
    res[i] = False
flag = {}
for i in range(N):
    flag[i] = True

for i in d:
    A = i[0]
    B = i[1]
    #print("H[A] > H[B]",H[A],H[B])
    if H[A] >= H[B] and flag[A] == True:
        res[A] = True
    else:
        flag[A] = False
        res[A] = False
    #print("H[A] < H[B]",H[A],H[B])
    if H[B] >= H[A] and flag[B] == True:
        res[B] = True
    else:
        flag[B] = False
        res[B] = False
print(list(res.values()).count(True))
#print(res)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
li_h=list(map(int,input().split()))
li_pair=[]
ans=0
for i in range(n):
    li_pair.append([])
for s in range(m):
    li=list(map(int,input().split()))
    li_pair[li[0]-1].append(li[1]-1)
    li_pair[li[1]-1].append(li[0]-1)
for i in range(n):
    lis=li_pair[i]
    if len(lis) != 0:
        if li_h[i]>=max(lis):
            ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
l = list(map(int, input().split()))
delist = list(range(1,n+1))
for i in range(m):
    a,b = map(int, input().split())
    if l[a-1] >= l[b-1]:
        if b in delist:
            delist.remove(b)
    else:
        if a in delist:
            delist.remove(a)
print(len(delist))

Submission status: Wrong Answer

Solution code:
n,m=map(int, input().split())
h = list(map(int, input().split()))
ab = [list(sorted(map(int, input().split()))) for i in range(m)]
ab = list(map(list, set(map(tuple, ab))))
includeList = []
for i in range(len(ab)):
    if includeList.count(ab[i][0]) > 0 or includeList.count(ab[i][1] > 0):
        continue
    elif h[ab[i][0]-1] < h[ab[i][1]-1]:
        n -= 1
        includeList.append(ab[i][0])
    elif h[ab[i][0]-1] > h[ab[i][1]-1]:
        n -= 1
        includeList.append(ab[i][1])
print(n)

Submission status: Wrong Answer

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

observatory_list = [{i: hs[i-1]} for i in range(n)]
bads = set()

for _ in range(m):
    a, b = map(int, input().split())
    
    for observatory in observatory_list:
        if a in observatory:
            observatory[b] = hs[b-1]            
            
        if b in observatory:
            observatory[a] = hs[a-1]
    
print(len({max(d, key=d.get) for d in observatory_list}))

Submission status: Wrong Answer

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

lisN = [[] for i in range(N)]
for i in range(M):
    inlis = list(map(int, input().split()))
    lisN[max(inlis)-1].append(lisH[min(inlis)-1])

ans = 0
for i in range(N):
    if len(lisN[i])>0:
        if lisH[i] > max(lisN[i]):
            ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
H = list(map(int,input().split()))
Hi_no = []
good = []
for i in range(N): 
    Hi_no.append(False)
    good.append(False)

for i in range(M):
    Aj,Bj = map(int, input().split())
    if H[Aj-1] > H[Bj-1]:
        good[Aj-1] = True
    elif H[Bj-1] > H[Aj-1]:
        good[Bj-1] = True
    Hi_no[Aj-1],Hi_no[Bj-1] = True,True

counter = 0
for i in range(N):
    if good[i] == True:
        counter += 1
    if Hi_no[i] == False:
        counter += 1
print(counter)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
A = list(map(int,input().split()))
num_list = []
i = 0
j = 0
k = 0
for i in range(M):
    b = list(map(int,input().split()))
    num_list = num_list+b
for j in range(int(len(num_list)/2)):
    if A[(num_list[j])-1] > A[(num_list[j+1])-1]:
        A[(num_list[j+1])-1] = 0
    if A[(num_list[j])-1] < A[(num_list[j+1])-1]:
        A[(num_list[j])-1] = 0
    if A[(num_list[j])-1] == A[(num_list[j+1])-1]: 
        A[(num_list[j])-1] = 0
        A[(num_list[j+1])-1] = 0 
    j = j+2
A = set(A)
A.remove(0)
print(len(A))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
p = []
lst = list(map(int, input().split()))
lst1 = [input().split() for _ in range(1,m+1)]
for i in range(m):
    k = int(lst1[i][0])
    v = int(lst1[i][1])
    a , b = int(lst[k-1]), int(lst[v-1])
    p.append(max(a,b))
print(len(set(p)))

Submission status: Wrong Answer

Solution code:
import numpy as np

n,m = map(int, input().split())
h = 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]:
        np.put(high, [a-1],1)
    elif h[a-1] < h[b-1]:
        np.put(high, [b-1],1)
    np.put(cnt, [a-1,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()))
j = []
for i in range(m):
    road = list(map(int, input().split()))
    road_inv = [road[1], road[0]]
    j.append(road)
    j.append(road_inv)
ans = 0
for i in range(n):
    road_i = [i for i, x in enumerate(j[:][0]) if x == i]
    if len(road_i) == 0:
        ans += 1
        continue
    good = True
    for rd in road_i:
        if h[j[rd][1]-1] > h[j[rd][0]-1]:
            good = False
    if good:
        ans += 1
ans = ans // 2
print(ans)

Submission status: Wrong Answer

Solution code:
from operator import itemgetter
n,m = map(int,input().split())
h = list(map(int,input().split()))
cnt = 0
st = sorted([list(map(int,input().split())) for i in range(m)],key = itemgetter(0))
graph = [False]*n
tansakuzumi = []
for i,j in st:
    
    if h[i-1] > h[j-1]:
        if [i,j] in tansakuzumi:
            pass
        else:
            graph[i-1] = True
        tansakuzumi.append([i,j])
    elif h[j-1] > h[i-1]:
        if [i,j] in tansakuzumi:
            pass
        else:
            graph[j-1] = True
        tansakuzumi.append([i,j])
    else:
        if [i,j] in tansakuzumi:
            pass
        else:
            graph[i-1] = True
        tansakuzumi.append([i,j])
for i in graph:
    if i:
        cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
NM =input().split()
N = int(NM[0])
M = int(NM[1])
H = input().split()
Nout = [1] * N
for i in range(M):
	road = input().split()
	print(road)
	if H[int(road[0]) - 1] < H[int(road[1]) - 1]:
		Nout[int(road[0]) - 1] = 0
	else:
		Nout[int(road[1]) - 1] = 0
def calc():
	j = 0
	for i in Nout:
		j += i
	return j
print(calc())

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(m):
    a,b = map(int, input().split())
    ma = max(h[a-1],h[b-1])
    if ma == h[a-1]:
        #ansList[a-1] = ma
        numlist.append(b-1)
    else:
        numlist.append(a-1)
for i in numlist:
    ansList[i] = 0
print(ansList.count(1))

Submission status: Wrong Answer

Solution code:
n , m = map(int, input().split())
h_list = map(int, input().split())
h_dict = {}
cnt = 1
m_cnt = 1
for i in h_list:
    h_dict[cnt] = i
    cnt += 1

new_dict = {}
while m_cnt <= m:
    n_1 , n_2 = map(int,input().split())
    try:
        v_1 = h_dict[n_1]
        v_2 = h_dict[n_2]
        if v_1 > v_2 :
            h_dict.pop(n_2)
        elif v_1 < v_2:
            h_dict.pop(n_1)
        else:
            h_dict.pop(n_1)
            h_dict.pop(n_2)

    except :
        pass

    m_cnt += 1

print(len(h_dict))

Submission status: Wrong Answer

Solution code:
NM = input().split()
N = int(NM[0])
M = int(NM[1])
H = list(map(int, input().split()))
IITODAI_FLAG = [0] * N
SYUTUGENTOUDAI =[]
 
for i in range(0, M):
  AB = input().split()
  A = int(AB[0])-1
  B = int(AB[1])-1
  SYUTUGENTOUDAI.append(A)
  SYUTUGENTOUDAI.append(B)
  if H[A]>H[B]:
    IITODAI_FLAG[A]=1
    IITODAI_FLAG[B]=0
  elif H[A]<H[B]:
    IITODAI_FLAG[A]=0
    IITODAI_FLAG[B]=1

NOT_SYUTUGENTOUDAI=N-len(list(set(SYUTUGENTOUDAI)))
IITODAI_FLAG_COUNT = IITODAI_FLAG.count(1)


print(NOT_SYUTUGENTOUDAI+IITODAI_FLAG_COUNT)

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 i[0]!=i[1]:    
        B[H.index(max(H[i[0]-1],H[i[1]-1]))]=1
print(B.count(0))

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
tenbo = input().split()
result = []
for i in range(len(tenbo)):
    tenbo[i] = int(tenbo[i])
A_B = [input().split() for i in range(M)]
for i in range(M):
    for j in range(2):
        A_B[i][j] = int(A_B[i][j])
#print(tenbo)
#print(A_B)
 
for i in range(M):
    tmp = max(tenbo[A_B[i][0]-1],tenbo[A_B[i][1]-1])
    result.append(tmp)
#print(result)
result.sort()
#print(result)
count = 0

for i in range(len(result)-1):
    if result[i] != result[i+1]:
        count += 1
if count != 0:
    count += 1
print(count)

Submission status: Wrong Answer

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

print(h2.count(0))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
keyList = list(range(1,N+1))
values = [True] * N
dic = dict(zip(keyList, values))
HList = list(map(int, input().split()))
ans = []

for i in range(M):
  a, b = map(int, input().split())
  H_a = HList[a-1]
  H_b = HList[b-1]
  if(dic[a] == True and (H_b == H_a or H_b > H_a)):
    dic[a] = False
  elif(dic[b] == True and (H_a == H_b or H_a > H_b)):
    dic[b] = False

i = 1
for v in dic.values():
  if(v == True):
    ans.append(dic[i])
    i += 1
print(len(ans))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
h = list(map(int, input().split()))
paths = [[0]*n for _ in range(n)]
results = [[0]*n for _ in range(n)]
for _ in range(m):
    x , y = map(int, input().split())
    results[x-1][y-1] = h[x-1] - h[y-1]
    results[y-1][x-1] = h[y-1] - h[x-1]
    
    paths[x-1][y-1] += 1
    paths[y-1][x-1] += 1

cnt = 0
for i in range(n):
    mb = 0
    flag = False
    if paths[i].count(0) == n:
        cnt += 1
    else:
        for j in range(n):
            if results[i][j] < 0:
                break
            elif results[i][j] >0:
                flag = True
                mb = paths[i][j] - 1
    if flag == True:
        cnt += 1 + mb
print(cnt)

Submission status: Wrong Answer

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

Tallest = [1]*N

for i in range (0,M):
	if H[int(P[i][0])-1] >= H[int(P[i][1])-1]:
		Tallest[P[i][1]-1]=0	
	elif H[int(P[i][0])-1] <= H[int(P[i][1])-1]:
		Tallest[P[i][0]-1]=0

print(sum(Tallest))

Submission status: Wrong Answer

Solution code:
import numpy as np
N, M = map(int, input().split(' '))

height = np.array(list(map(int, input().split(' '))))
#height_all = height

for i in range(M):
  a, b = map(int, input().split(' '))
  #print(a, b, height[a - 1], height[b - 1])
  if height[a - 1] > height[b - 1]:
    height[b - 1] = 0
   
  else:
    height[a - 1] = 0
#print(height)
print(len(np.nonzero(height)[0]))

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
Hs = []
roads = []
tunagatteru = []
Hs = list(map(int,input().split()))
ans = 0
for i in range(M):
    a,b = map(int,input().split())
    roads.append([a,b])

for i in range(N):
    height = Hs[i]
    peaks = []
    for j in roads:
        if j[0] == i+1:
            peaks.append(j[1])
        if j[1] == i+1:
            peaks.append(j[0])
    tunagatteru.append(peaks)
for i in range(N):
    if tunagatteru[i] == []:
        ans+=1
    else:
        for j in tunagatteru[i]:
            if Hs[j-1] < Hs[i]:
                ans+=1
print(ans-1)

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

ans = []
for i in range(n):
    n_ex = []
    for j in range(m):
        ab_ex = ab[j]
        if ((i+1) in ab_ex):
            index_root = ab_ex.index(i+1)
            if (index_root == 0 and ((ab_ex[1]-1) not in n_ex)):
                n_ex.append(ab_ex[1]-1)
            elif (index_root == 1 and ((ab_ex[0]-1) not in n_ex)):
                n_ex.append(ab_ex[0]-1)
    if (len(n_ex) == 0):
        ans.append(i)
        break
    else:
        for k in range(len(n_ex)):
            if (h[i] > h[n_ex[k]] and k == (len(n_ex)-1)):
                ans.append(i)
            elif(h[i] <= h[n_ex[k]]):
                break

print(len(ans))

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
H = list(map(int,input().split()))
datas = []
ans = []
count = 1
dic = []
for h in H:
    dic.append({count:h})
    count += 1
for i in range(M):
    datas.append(list(map(int,input().split())))
for data in datas:
    a,b = data
    if H[a-1] > H[b-1]:
        ans.append(a)
    else:
        ans.append(b) 
print(len(set(ans)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ansdic = {}

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


ans = 0

for h in Hlist:
    if h in ansdic:
        if ansdic[h]:
            ans += 1
    else:
        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 m in range(M)]
AB = list(map(list, set(map(tuple, AB))))

i = []
for m in range(len(AB)):
    a = AB[m][0]
    b = AB[m][1]
    if H[a-1] >= H[b-1]:
        i.append(b-1)
    elif H[a-1] <= H[b-1]:
        i.append(a-1)

i = list(set(i))
for x in i:
    H[x] = 0

cnt = H.count(0)
print(len(H)-cnt)

Submission status: Wrong Answer

Solution code:
class Test:
  tenboulist = []
  tenboudaiSu = 0
  ways = 0
  goodcount = 0
  jisyo = {}
        
  def __init__(self):
    inp = input()
    inplist1 = inp.split()
    tenboudaiSu = int(inplist1[0])
    ways = int(inplist1[1])
    
    inp2 = input()
    tenboudailiststr = inp2.split()
    work = 0
    for i in range(tenboudaiSu):
      self.jisyo[tenboudailiststr[work]] = True
      work += 1
   
    for i in tenboudailiststr:
      self.tenboulist.append(int(i))
    
    inplist2 = [input() for i in range(ways)]
    
    for i in inplist2:
      inwork = i.split()
      froma = int(inwork[0])
      tob = int(inwork[1])
      self.judge(froma , tob)
      
    #print(self.jisyo)
    for i in self.jisyo.values():
      if(i):
        self.goodcount += 1
      
    print(self.goodcount)

  def judge(self,A,B):
    #print("{}と{}を比較".format(self.tenboulist[A-1],self.tenboulist[B-1]))
    if (self.tenboulist[A-1] == self.tenboulist[B-1]):
      self.jisyo[str(A)] = False
      self.jisyo[str(B)] = False
    elif (self.tenboulist[A-1] < self.tenboulist[B-1]):
      self.jisyo[str(A)] = False
    else :
      self.jisyo[str(B)] = False


        
test = Test()

Submission status: Wrong Answer

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

n, m = map(int, input().split())
h = np.array(input().split(), dtype='int')
good_tower = np.arange(1, n+1)
bad_tower = np.zeros((), dtype='int')

for i in range(m):
    way = np.array(input().split(), dtype='int')

    if h[way[0]-1] > h[way[1]-1]:
        bad_tower = np.append(bad_tower, way[1])
    elif h[way[0]-1] < h[way[1]-1]:
        bad_tower = np.append(bad_tower, way[0])
    elif h[way[0]-1] == h[way[1]-1]:
        bad_tower = np.append(bad_tower, way[0])
        bad_tower = np.append(bad_tower, way[1])

bad_tower = np.array(list(set(bad_tower)))

ans = len(good_tower) - len(bad_tower) - 1

print(ans)

Submission status: Wrong Answer

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

for a in List:
    result.append(a)

for i in range(m):
    lis=list(map(int,input().split()))#2個をｍ回
    s.append(lis)

for slist in s:
    a=slist[0]
    b=slist[1]
    if List[a-1]>=List[b-1]:
        if List[b-1] in result:
            result.remove(List[b-1])
    else:
        if List[a-1] in result:
            result.remove(List[a-1])

t=set(result)       
print(len(t))

Submission status: Wrong Answer

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

print(h2.count(0))

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
Hl = list(map(int,input().split()))
Ll = []
for _ in range(M):
    Ll.append(list(map(int,input().split())))

win = []
lose = []
draw = []
for L in Ll:
    x,y = L
    if(Hl[x-1]>Hl[y-1]):
        win.append(x)
        lose.append(y)
    elif(Hl[x-1]<Hl[y-1]):
        win.append(y)
        lose.append(x)
    else:
        draw.append(y)
        draw.append(x)

ind_num = N - len(set(win+lose+draw))
ans = set(win) - set(lose)
print(len(ans)+ind_num)

Submission status: Wrong Answer

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

for i in range(M):
    A = [int(i) for i in input().split()]
    if H[A[0] - 1] < H[A[1] - 1]:
        X.append(A[0])
    elif H[A[0] - 1] > H[A[1] - 1]:
        X.append(A[1])
    else:
        X.append(A[0])
        X.append(A[1])

for i in range(N):
    if X.count(i+1) == 0:
        cnt += 1
        
print(N - cnt)

Submission status: Wrong Answer

Solution code:
NM = input().split()
N = int(NM[0])
M = int(NM[1])
H = list(map(int, input().split()))
IITODAI_FLAG = [0] * N
SYUTUGENTOUDAI =[]
 
for i in range(0, M-1):
  AB = input().split()
  A = int(AB[0])-1
  B = int(AB[1])-1
  SYUTUGENTOUDAI.append(A)
  SYUTUGENTOUDAI.append(B)
  if H[A]>H[B]:
    IITODAI_FLAG[A]=1
    IITODAI_FLAG[B]=0
  elif H[A]<H[B]:
    IITODAI_FLAG[A]=0
    IITODAI_FLAG[B]=1

NOT_SYUTUGENTOUDAI=N-len(list(set(SYUTUGENTOUDAI)))
IITODAI_FLAG_COUNT = IITODAI_FLAG.count(1)


print(NOT_SYUTUGENTOUDAI+IITODAI_FLAG_COUNT)

Submission status: Wrong Answer

Solution code:
import numpy as np

inputs = []
while True:
  try:
    inputs.append(input())
  except EOFError:
    break

obsv = eval(inputs[0].split(" ")[0])
heights = [eval(a) for a in inputs[1].split(" ")]
ways = sorted(set(inputs[2:]))
ways = [[eval(b) for b in a.split(" ")] for a in ways]
no_conn = obsv - len(set(sum(ways, [])))

ways_inv = [[j,i] for [i,j] in ways]
ways.extend(ways_inv)
ways = sorted(ways)

count = no_conn
start = 1
is_good = []
for w in ways:
  is_good.append(heights[start-1] > heights[w[1]-1])
  if start != w[0]:
    if np.all(is_good):
        count += 1
    start = w[0]
    is_good = []
if np.all(is_good):
  count += 1
  
print(count)

Submission status: Wrong Answer

Solution code:
import numpy as np
N, M = map(int, input().split(' '))

height = np.array(list(map(int, input().split(' '))))
#height_all = height

for i in range(M):
  a, b = map(int, input().split(' '))
  #print(a, b, height[a - 1], height[b - 1])
  if height[a - 1] > height[b - 1]:
    height[b - 1] = 0
   
  else:
    height[a - 1] = 0
  
print(len(np.nonzero(height)))

Submission status: Wrong Answer

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

lst = [-1] * n

for i in range(m):
  a, b = map(int, input().split())
  if h[a-1] > h[b-1]:
    lst[b-1] = max(h[a-1], h[b-1])
  else:
    h[a-1] = max(h[a-1], h[b-1])
    
for j in range(len(lst)):
  if lst[j] == -1:
    lst[j] = h[j]
print(len(set(lst)))

Submission status: Wrong Answer

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

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

A = [0] * M
B = [0] * M
# count = 0
for i in range(M):
    A[i], B[i] = map(int, input().split())

# for i in range(1, N+1):
#     if not (i in A) and not (i in B):
#         count += 1
# print(count)
taller = []
smaller = []

for i in range(M):
    taller.append(max([H[A[i]-1], H[B[i]-1]]))
    smaller.append(min([H[A[i]-1], H[B[i]-1]]))

A.extend(B)

# count = count + len(set(taller))
print(N - len(set(A)) + len(set(taller)) - len(list(set(taller) & set(smaller))))

Submission status: Wrong Answer

Solution code:
import copy
n,m=map(int,input().split())
h = list(map(int,input().split()))
h1=copy.copy(h)
a=[]
for i in range(m):
    A,B=map(int,input().split())
    a.append(A)
    a.append(B)
    if h[A-1]>h[B-1]:
        #ans.append(A-1)
        h[B-1]=h[A-1]
    elif h[A-1]<h[B-1]:
        #ans.append(B-1)
        h[A-1]=h[B-1]
ans=0
for i in range(n):
    if h[i]==h1[i]:
        ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
H=list(map(int,input().split()))
T=[0]*N
ans=0
li=[list(map(int,input().split())) for _ in range(M)]
for l in li:
  if H[l[0]-1]>H[l[1]-1]:
    T[l[0]-1]+=1
    T[l[1]-1]-=10**5
  if H[l[0]-1]<H[l[1]-1]:
    T[l[0]-1]-=10**5
    T[l[1]-1]+=1
  else:
    T[l[0]-1]=T[l[1]-1]=-(10**5)
for t in T:
  if t>=0:
    ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
h = list(map(int, input().split()))
road = []
for _ in range(m):
    road.append(list(map(int, input().split())))
    
c = [0]*len(h)
for i in range(1, len(h)+1):
    for r in road:
        if i in r:
            dummy = r[:]
            dummy.remove(i)
            c[i-1] = max(c[i-1], dummy[0])
            
ans = 0
for i in range(len(c)):
    if c[i] == 0:
        ans += 1
    elif h[c[i]-1] < h[i]:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split(" "))
h_list = list(map(int,input().split(" ")))
road = [[] for i in range(N)]
for i in range(M):
    a,b = map(int,input().split(" "))
    if a<b and b-1 not in road[a-1]:
        road[a-1].append(b-1)
    elif b<a and a-1 not in road[b-1]:
        road[b-1].append(a-1)
good_obs = [0 for i in range(N)]
for i in range(N):
    if len(road[i]) == 0 and good_obs[i] == 0:
        good_obs[i] = 1
    elif len(road[i])!=0:
        h_max = 0
        same_flag = 0
        max_index = -1
        road[i].append(i)
        for j in road[i]:
            if h_max == h_list[j]:
                same_flag = 1
            elif h_max < h_list[j]:
                h_max = h_list[j]
                same_flag = 0
                max_index = j
        if same_flag == 0:
            if good_obs[max_index] !=-1:
                good_obs[max_index] = 1
        for j in road[i]:
            if good_obs[j] != 1:
                good_obs[j] = -1
print(good_obs.count(1))

Submission status: Wrong Answer

Solution code:
NM = input().split()
N = int(NM[0])
M = int(NM[1])
H = list(map(int, input().split()))
IITODAI_FLAG = [0] * N
SYUTUGENTOUDAI =[]
 
for i in range(0, M):
  AB = input().split()
  A = int(AB[0])-1
  B = int(AB[1])-1
  SYUTUGENTOUDAI.append(A)
  SYUTUGENTOUDAI.append(B)
  if H[A]>H[B]:
    IITODAI_FLAG[A]=1
    IITODAI_FLAG[B]=0
  elif H[A]<H[B]:
    IITODAI_FLAG[A]=0
    IITODAI_FLAG[B]=1

 # 一回も出てこない東大と1のフラグの東大の和
NOT_SYUTUGENTOUDAI=N-len(list(set(SYUTUGENTOUDAI)))
IITODAI_FLAG_COUNT = IITODAI_FLAG.count(1)


print(NOT_SYUTUGENTOUDAI+IITODAI_FLAG_COUNT)

Submission status: Wrong Answer

Solution code:
def main():
    N, M = map(int, input().split())
    Hn_list = [A for A in input().split()]
    Hn_list = list(map(int, Hn_list))
    j_list = []
    temp_list = []
    temp_c_list = []
    for i in range(M):
        A, B = map(int, input().split())
        temp_list = [A,B]
        temp_c_list = [B,A]
        if temp_list in j_list or temp_c_list in j_list :
            pass
        else :
            j_list.append(temp_list)
        temp_list = []
        temp_c_list = []
    #print(j_list)
    Hn_pop_list = []
    for pair_list in j_list :
        temp_a = int(pair_list[0]-1)
        temp_b = int(pair_list[1]-1)
        if Hn_list[temp_a] > Hn_list[temp_b] :
            Hn_pop_list.append(Hn_list[temp_a])
        elif Hn_list[temp_b] > Hn_list[temp_a]:
            Hn_pop_list.append(Hn_list[temp_b])

    Hn_pop_list = list(set(Hn_pop_list))
    for delval in Hn_pop_list :
        Hn_list.remove(delval)
    Hn_list = list(set(Hn_list))
    print(len(Hn_list))
    #print(Hn_list)
    #print(Hn_pop_list)

if __name__ == '__main__':
    main()

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):
    A1,B1=map(int, input().split())
    A.append(A1)
    B.append(B1)
miti={}
for i in range(M):
    if A[i] in miti:
        miti[A[i]].append(H[B[i]-1])            
    else:
        miti[A[i]]=[]
        miti[A[i]].append(H[B[i]-1])
    if B[i] in miti:
        miti[B[i]].append(H[A[i]-1])            
    else:
        miti[B[i]]=[]
        miti[B[i]].append(H[A[i]-1])
count=0
for i in range(M):
    if i+1 in miti:
        for j in range(len(miti[i+1])):
            if H[i]<=miti[i+1][j]:
                count+=1
                break
print(N-count)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
H = list(map(int,input().split()))
List = []
List2 = []
List3 = []
for i in range(m):
    a,b = map(int,input().split())
    List3.append(a)
    List3.append(b)
    if H[a-1] > H[b-1]:
        if not a in List2:
            List.append(a)
        List2.append(b)
    elif H[a-1] < H[b-1]:
        if not b in List2:
            List.append(b)
        List2.append(a)
    
ans = len(set(List)) + n - len(set(List3))
if ans < 0:
    ans = 0
print(ans)

Submission status: Wrong Answer

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

par = [0 for i in range(N)]

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

print(N-sum(par))

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
H=list(map(int,input().split()))
c=[0]*n
for i in range(m):
    a,b=map(int,input().split())
    if H[a-1]<=H[b-1]:
        c[a-1]+=1
    elif H[b-1]<=H[a-1]:
        c[b-1]+=1
x=0
for y in c:
    if y==0:
        x+=1

print(x)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
hlist = list(map(int,input().split()))
ten = []
append = ten.append
for i in range(n):
    append(1)
#print(ten)
for i in range(m):
    a,b = map(int,input().split())
    if hlist[a-1] >= hlist[b-1]:
        ten[b-1] = 0
    elif hlist[b-1] >= hlist[a-1]:
        ten[a-1] = 0

print(sum(ten))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
h=list(map(int,input().split()))
road=[]
for i in range(m):
    road.append(list(map(int,input().split())))
tall=[1 for _ in range(n)]
for i in range(m):
    if h[road[i][0]-1]>=h[road[i][1]-1]:
        tall[road[i][1]-1]=0
    else:
        tall[road[i][0]-1]=0
counter=0
for i in range(n):
    if tall[i] == 1:
        counter+=1
print(counter)

Submission status: Wrong Answer

Solution code:
#--Peaks
import itertools
from collections import Counter

N, M = map(int, input().split())
height = [int(i) for i in input().split()]

A = []
B = []
root = [[int(j) for j in input().split()] for i in range(M)]

judge = list(range(1,N+1)) # tennboudai no honsu

for i in range(M):
  q1 = root[i][0]
  q2 = root[i][1]
  if(height[q1-1] > height[q2-1]):
    judge[q2-1] = 0
  elif(height[q1-1] < height[q2-1]):
    judge[q1-1] = 0
  else:
    pass

o = 2
c = Counter(tuple(x) for x in root)
double = [list(k) for k,v in c.items() if v==o]
number = len(double)

for i in range(number):
  q1 = double[i][0]
  q2 = double[i][1]
  judge[q1-1] = 0
  judge[q2-1] = 0

correct = [n for n in judge if n!=0]
#print(correct)
print(len(correct))

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):
    A1,B1=map(int, input().split())
    A.append(A1)
    B.append(B1)
miti={}
for i in range(M):
    if A[i] in miti:
        miti[A[i]].append(H[B[i]-1])            
    else:
        miti[A[i]]=[]
        miti[A[i]].append(H[B[i]-1])
    if B[i] in miti:
        miti[B[i]].append(H[A[i]-1])            
    else:
        miti[B[i]]=[]
        miti[B[i]].append(H[A[i]-1])
count=0
print(miti)
for i in range(M):
    if i+1 in miti:
        for j in range(len(miti[i+1])):
            if H[i]<=miti[i+1][j]:
                count+=1
                print(i+1)
                break
print(N-count)