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:
# abc166_c.py
# https://atcoder.jp/contests/abc166/tasks/abc166_c

# C - Peaks /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 300点

# 問題文
# AtCoder丘陵には N個の展望台があり、展望台 i の標高は Hi です。 
# また、異なる展望台どうしを結ぶ M 本の道があり、道 j は展望台 Aj と展望台 Bjを結んでいます。
# 展望台 iが良い展望台であるとは、展望台 i から一本の道を使って辿り着けるどの展望台よりも展望台 i の方が標高が高いことをいいます。 
# 展望台 i から一本の道を使って辿り着ける展望台が存在しない場合も、展望台 iは良い展望台であるといいます。
# 良い展望台がいくつあるか求めてください。

# 制約
#     2≤N≤105
#     1≤M≤105
#     1≤Hi≤109
#     1≤Ai,Bi≤N
#     Ai≠Bi
#     同じ展望台の組を結ぶ道が複数あることもある。
#     入力中の値はすべて整数である。

# 入力
# 入力は以下の形式で標準入力から与えられる。
# N M
# H1 H2 ... HN
# A1 B1
# A2 B2
# :
# AM BM

# 出力
# 良い展望台の数を出力せよ。

# 入力例 1
# 4 3
# 1 2 3 4
# 1 3
# 2 3
# 2 4

# 出力例 1
# 2

#     展望台 1から一本の道を使って辿り着ける展望台は展望台 3 ですが、展望台 1 の標高は展望台 3 の標高より高くないため、展望台 1は良い展望台ではありません。
#     展望台 2から一本の道を使って辿り着ける展望台は展望台 3 と展望台 4 ですが、展望台 2 の標高は展望台 3 の標高より高くないため、展望台 2は良い展望台ではありません。
#     展望台 3から一本の道を使って辿り着ける展望台は展望台 1 と展望台 2 ですが、展望台 3 の標高は展望台 1 の標高より高く、かつ展望台 2 の標高より高いため、展望台 3は良い展望台です。
#     展望台 4から一本の道を使って辿り着ける展望台は展望台 2 ですが、展望台 4 の標高は展望台 2 の標高より高いため、展望台 4は良い展望台です。
# 展望台 3と展望台 4 が良い展望台なので、良い展望台の数は 2です。

# 入力例 2
# 6 5
# 8 6 9 1 2 1
# 1 3
# 4 2
# 4 3
# 4 6
# 4 6

# 出力例 2
# 3


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    S = lines[0]
    # N = int(lines[0])
    N, M = list(map(int, lines[0].split()))
    values_h = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    valueses = list()
    for i in range(M):
        valueses.append(list(map(int, lines[i+2].split())))

    result = 0

    for n in range(N):
        flag = True
        for values in valueses:
            t = None
            if values[0] == n:
                t = values[1]
            elif values[1] == n:
                t = values[0]
            if t is not None:
                if values_h[t-1] >= values_h[n]:
                    flag = False
        if flag:
            result += 1

    return [result]


# 引数を取得
def get_input_lines():
    line = input()
    N, M = list(map(int, line.split()))
    lines = list()
    lines.append(line)
    for _ in range(M+1):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['4 3', '1 2 3 4', '1 3', '2 3', '2 4']
        lines_export = [2]
    if pattern == 2:
        lines_input = ['6 5', '8 6 9 1 2 1', '1 3', '4 2', '4 2', '4 6', '4 6']
        lines_export = [3]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines()
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
H = list(map(int, input().split()))
I = [list(map(int, input().split())) for i in range(M)]
A = B = [0] * M
for i in range(M):
    A[i] = I[i][0]
    B[i] = I[i][1]

i = 1
ans = [1] * N

while i <= N:
    for j in range(M):
        if i == A[j]:
            if H[i-1] <= H[B[j]-1]:
                ans.pop(0)
                break
        elif i == B[j]:
            if H[i-1] <= H[A[j]-1]:
                ans.pop(0)
                break
    i += 1
    
print(len(ans))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
H = list(map(int, input().split()))
I = [list(map(int, input().split())) for i in range(M)]
A = B = [0] * M
for i in range(M):
    A[i] = I[i][0]
    B[i] = I[i][1]

i = 0
ans = [1] * N

while i <= N:
    i += 1
    for j in range(M):
        if i == A[j]:
            if H[i-1] <= H[B[j]-1]:
                ans.pop(0)
                break
        elif i == B[j]:
            if H[i-1] <= H[A[j]-1]:
                ans.pop(0)
                break

print(len(ans))

Submission status: Wrong Answer

Solution code:
def main():
    n,m = map(int,input().split())
    heights = list(map(int,input().split()))
    roads = [[] for _ in range(n)]
    for i in range(m):
        #入力は1-indexed
        #roadsリストは0-indexed
        a,b = map(int,input().split())
        a = a - 1
        b = b - 1

        roads[a].append(b)
        roads[b].append(a)

    def is_good(t):
        self_height = heights[t]
        dests = roads[t]
        for d in dests:
            if d >= self_height:
                return False
        return True
    print(len([d for d in range(n) if is_good(d)]))





if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np
n,m = map(int,input().split())
a = list(map(int,input().split()))
b = np.ones(n)

for _ in range(m):
    p,q = map(int,input().split())
    if a[p-1] >= a[q-1]:
        b[q-1] = 0
    else:
        b[p-1] = 0

print(int(b.sum()))

Submission status: Wrong Answer

Solution code:
import sys
import time
import math
import itertools as it
def inpl():
    return list(map(int, input().split()))
st = time.perf_counter()
# ------------------------------

N, M = inpl()
H = inpl()
for _ in range(M):
    A, B = inpl()
    if H[A-1] > H[B-1]:
        H[B-1] = 0
    elif H[A-1] < H[B-1]:
        H[A-1] = 0
    else:
        H[A-1] = 0
        H[B-1] = 0
ans = 0
for i in H:
    if i != 0:
        ans += 1
print(ans)

# ------------------------------
ed = time.perf_counter()
print('time:', ed-st, file=sys.stderr)

Submission status: Wrong Answer

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

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

print(sum(nl)+(n-sum(check)))

Submission status: Wrong Answer

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

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

print(sum(nl)+(n-sum(check)))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N, M = (int(x) for x in input().split())
H=list(map(int, input().split()))
check=[True]*N
ans=N
for i in range(M):
  A, B = (int(x) for x in input().split())
  if check[A-1]==True and H[A-1]<=H[B-1]:
    check[A-1]=False
    ans-=1
  elif check[B-1]==True and H[A-1]>=H[B-1]:
    check[B-1]=False
    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 i in range(M)]
s = []; t = 0
for i in range(M):
    if h[ab[i][0]-1] < h[ab[i][1]-1]:
        s.append(ab[i][0])
    elif h[ab[i][0]-1] > h[ab[i][1]-1]:
        s.append(ab[i][1])
for i in range(N):
    if i not in s:
        t += 1
print(t)

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

tf_array = [0]*N

for a, b in AB:
    print(a,b)
    if H[a-1] > H[b-1]:
        tf_array[b-1] += 1
    elif H[a-1] == H[b-1]:
        tf_array[a-1] += 1
        tf_array[b-1] += 1
    else:
        tf_array[a-1] += 1

print(tf_array.count(0))

Submission status: Wrong Answer

Solution code:

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

good = 0

obs = [[]*n]

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

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
H = sorted(enumerate((map(int, input().split()))), reverse=True, key=lambda x: x[1])
table = []
for i in range(N):
    table.append(set())
for i in range(M):
    Ai, Bi = map(lambda x: x - 1, map(int, input().split()))
    table[Ai].add(Bi)
    table[Bi].add(Ai)
memo = {}
answer = 0
prev = -1
for h in H:
    for path in table[h[0]]:
        memo[path] = True
    if h[1] == prev:
        continue
    prev = h[1]
    if h[0] in memo:
        continue
    answer += 1
print(answer)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
H = sorted(enumerate((map(int, input().split()))), reverse=True, key=lambda x: x[1])
table = []
for i in range(N):
    table.append(set())
# print(H)
for i in range(M):
    Ai, Bi = map(lambda x: x - 1, map(int, input().split()))
    table[Ai].add(Bi)
    table[Bi].add(Ai)
# print(table)
memo = {}
answer = 0
prev = -1
for h in H:
    if h[1] == prev:
        continue
    prev = h[1]
    if h[0] in memo:
        continue
    answer += 1
    for path in table[h[0]]:
        memo[path] = True
print(answer)

Submission status: Wrong Answer

Solution code:

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

print(sum(d))

Submission status: Wrong Answer

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

for i in range(m):
    x = a[i] - 1
    y = b[i] - 1
    if h[x] < h[y]:
        z[x] = 0
    else:
        z[y] = 0

print(n - z.count(0))

Submission status: Wrong Answer

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

for i in range(m):
    x = a[i] - 1
    y = b[i] - 1
    if h[x] < h[y]:
        z[x] = 0
    else:
        z[y] = 0

print(z)
print(n - z.count(0))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(len(height_list) - len(eliminate_list))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
d=defaultdict(list)
n ,m =list(map(int,input().split()))
h=list(map(int,input().split()))
for i in range(m):
    a,b=list(map(int,input().split()))
    d[a].append(b)
    d[b].append(a)
s=0
for c in d:
    k=0
    for v in d[c]:
        if h[c-1]<=h[v-1]:
            k=1
            break
    #print(c,k,d)
    if k==0:
        s+=1
print(s)

Submission status: Wrong Answer

Solution code:
import math
import collections
import fractions
import itertools
import functools
import  operator

def solve():
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    oka = list(list() for _ in range(n))
    for _ in range(m):
        a, b = map(int, input().split())
        oka[a-1].append(h[b-1])
        oka[b-1].append(h[a-1])
    cnt = 0
    for i in range(n):
        if len(oka[i])==0 or max(oka[i])<=i+1:
            cnt += 1
    print(cnt)
    return 0

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
n, m = M()
h_list = LI()
ans_list = [1] * n
for _ in range(m):
    a, b = M()
    if h_list[a-1] < h_list[b-1]:
        ans_list[a-1] = 0
    else:
        ans_list[b-1] = 0
print(sum(ans_list))

Submission status: Wrong Answer

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

H_list = []

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

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

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

ans = 0

for i in range(N):
    j = 1
    while j < len(H_list[i]):
        if H[H_list[i][0]-1] <= H[H_list[i][j]-1]:
            H_list[i].clear()
            break
        else:
            H_list[H_list[i][j]-1].clear()
            j += 1
    if len(H_list[i]) >= 1:
        ans += 1

print(ans)

Submission status: Wrong Answer

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

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

    if h[a-1] < h[b-1]:
        chk[b-1] += 1
    chk[a-1] += 1
    chk[b-1] += 1
print(cnt)
print(chk)
for i in range(n):
    if cnt[i] == chk[i]:
        ans += 1

print(ans)

Submission status: Wrong Answer

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

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

    if h[a-1] < h[b-1]:
        cnt[b-1] += 1
    chk[a-1] += 1
    chk[b-1] += 1
print(cnt)
print(chk)
for i in range(n):
    if cnt[i] == chk[i]:
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
n, m = list(map(int, input().split()))
arr=[0]+list(map(int,input().split()))
g = [[] for _ in range(n+1)]
print(g)
for _ in range(m):
    a, b = map(int, input().split())
    g[a].append(b)
    g[b].append(a)
print(g)
ans = 0
for v in range(1, n+1):
     #i番目の展望台から1本の道を通っていけるすべての展望台と高さを比較する
    for u in g[v]:
        if arr[u]>=arr[v]:
            break
        #i番目の展望台の高さが他のすべての展望台の高さより真に大きければ答えを1増やす
        else:
            ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    n, m = (int(i) for i in input().split())
    h = [int(i) for i in input().split()]
    roads = [(int(i) for i in input().split()) for _ in range(m)]

    nbors = [[] for _ in range(n)]
    for a, b in roads:
        nbors[a-1].append(b-1)
        nbors[b-1].append(a-1)

    ngood = 0
    for o in range(n):
        if all(h[o] > h[nb] for nb in nbors[o]):
            ngood += 1

    return ngood

main()

Submission status: Wrong Answer

Solution code:

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

good_list = [0]*n

for i in range(m):
    a, b = ab[i][0], ab[i][1]
    if h[a-1] < h[b-1]:
        good_list[b-1] = 1
    elif h[a-1] > h[b-1]:
        good_list[a-1] = 1
    else:
        good_list[a-1] = 1
        good_list[b-1] = 1

print(good_list.count(0))

Submission status: Wrong Answer

Solution code:

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

good_list = []
for i in range(m):
    a, b = ab[i][0], ab[i][1]
    good_list.append(max(h[a-1], h[b-1]))

print(len(set(good_list)))

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
h = [0]
h.extend([int(i) for i in input().split()])
bld = [0]*(n+1)

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

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
H=list(map(int,input().split()))
P=[]
for i in range(M):
    P.append(list(map(int,input().split()))) #2次元配列、P[A_i,B_i]

ans=[]

for i in range(M):
    if H[P[i][0]-1]>H[P[i][1]-1]:   #H[A_i]>H[B_i]ならばA_iを加える
        ans.append(P[i][0])
    elif H[P[i][0]-1]<H[P[i][1]-1]: #H[A_i]<H[B_i]ならばB_iを加える
        ans.append(P[i][1])       
    else:                           #H[A_i]=H[B_i]ならば何もしない
        continue                    
    
list=[]

for j in range(M):
      list.append(P[j][0])
      list.append(P[j][1])
print(len(set(ans))+N-len(set(list)))

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
H=list(map(int,input().split()))
P=[]
for i in range(M):
    P.append(list(map(int,input().split()))) #2次元配列、P[A_i,B_i]

ans=[]

for i in range(M):
    if H[P[i][0]-1]>H[P[i][1]-1]:   #H[A_i]>H[B_i]ならばA_iを加える
        ans.append(P[i][0])
    elif H[P[i][0]-1]<H[P[i][1]-1]: #H[A_i]<H[B_i]ならばB_iを加える
        ans.append(P[i][1])       
    else:                           #H[A_i]=H[B_i]ならば何もしない
        continue                    
    
list=[]

for j in range(M): 
    list+=P[j]

print(len(set(ans))+N-len(set(list)))

Submission status: Wrong Answer

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

for i in range(m):
    if h[A[i] - 1] > h[B[i] - 1]:
        p[B[i]] = False
    if h[A[i] - 1] < h[B[i] - 1]:
        p[A[i]] = False
    else:
        p[A[i]] = False
        p[B[i]] = False

ans = [i for i in range(n + 1) if p[i]]

print(len(ans))

Submission status: Wrong Answer

Solution code:
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
N,M=MI()
H=[0]+LI()
L=[[] for i in range(N+1)]
ans=0
for _ in range(M):
  a,b=MI()
  L[a].append(b)
  L[b].append(a)
for i in range(1,N+1):
  for j in L[i]:
    #print(i,H[i],j,H[j])
    if H[i]<=H[j]:
      break
  ans+=1
ans//=2
print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n,m=nii()
h=lnii()

tree=[[] for i in range(n)]
for i in range(m):
  a,b=nii()
  a-=1
  b-=1
  tree[a].append(b)
  tree[b].append(a)

ans=0
for i in range(n):
  if tree[i] and h[i]>max(tree[i]):
    ans+=1

print(ans)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
list1 = list(map(int, input().split()))
list2 = [1] * n
for _ in range(m):
    a, b = map(int, input().split())
    if list1[a - 1] < list1[b - 1]:
        list2[a - 1] = 0
    else:
        list2[b - 1] = 0
print(list2.count(1))

Submission status: Wrong Answer

Solution code:
def mi(): return map(int,input().split())
def lmi(): return list(map(int,input().split()))
def ii(): return int(input())
def isp(): return input().split()

n,m=mi()
h=lmi()
list_ans=[]
visited=[0]*n
for i in range(m):
  a,b=mi()
  if h[a-1]<h[b-1] or h[a-1]>h[b-1]:
    list_ans.append(max(h[a-1],h[b-1]))
  
  visited[a-1]=1
  visited[b-1]=1

if len(list_ans)==0:
  s=0
else:
  s_=list(set(list_ans))
  #print(s_)
  #print(visited)
  s=len(s_)
t=visited.count(0)
print(s+t)

Submission status: Wrong Answer

Solution code:
def mi(): return map(int,input().split())
def lmi(): return list(map(int,input().split()))
def ii(): return int(input())
def isp(): return input().split()

n,m=mi()
h=lmi()
list_ans=[]
visited=[0]*n
for i in range(m):
  a,b=mi()
  if h[a-1]<h[b-1] or h[a-1]>h[b-1]:
    list_ans.append(max(h[a-1],h[b-1]))
  
  visited[a-1]+=1
  visited[b-1]+=1

s_=list(set(list_ans))
#print(s_)
#print(visited)
s=len(s_)
t=visited.count(0)
print(s+t)

Submission status: Wrong Answer

Solution code:
import numpy as np

def solve():
    dp = np.zeros(N+1)
    a = []
    for i in range(M):
        dp[AB[i][0]] = AB[i][1]
        if AB[i][1] not in a:
            a.append(AB[i][1])
#    print(dp)
#    print(a)
    print(len(a))


if __name__ == "__main__":
    N,M = list(map(int, input().split()))
    H = list(map(int, input().split()))
    AB = [list(map(int, input().split())) for _ in range(M)]
    solve()

Submission status: Wrong Answer

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

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

ans = [1]*N

for i in range(M):
    A, B = list(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
    else:
        H[A-1] = 0
        H[B-1] = 0

print(sum(ans))

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
H = list(map(int,input().split()))
from collections import defaultdict
dic = defaultdict(list)
for _ in range(M):
  a, b = map(int,input().split())
  dic[a].append(b)
  dic[b].append(a)
counter = 0
for item in dic:
  for c in dic[item]:
    flag = 1
    if H[c-1] > H[item - 1]:
      flag = 0
      break
  if flag == 1:
    counter +=1
print(counter)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
H = list(map(int,input().split()))
from collections import defaultdict
dic = defaultdict(list)
for _ in range(M):
  a, b = map(int,input().split())
  dic[a].append(b)
  dic[b].append(a)
counter = 0
for item in dic:
  if max(dic[item]) <= H[item - 1]:
    counter +=1
print(counter)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Wed Jul  1 07:13:55 2020

@author: Aruto Hosaka
"""


N = list(map(int, input().split()))
H = list(map(int, input().split()))
B = [list(map(int, input().split())) for i in range(N[1])]

# N = [6, 5]
# H = [8, 6, 9, 1, 2, 1]
# B = [[1, 3], [4, 2], [4, 3], [4, 6], [4, 6]]

# N = [4, 3]
# H = [1, 2, 3, 4]
# B = [[1, 3],[2, 3],[2, 4]]

counter = [1 for i in range(N[0])]

for b in B:
    if H[b[1]-1] > H[b[0]-1] and counter[b[1]-1] == 1:
        counter[b[0]-1] = 0
    elif H[b[0]-1] > H[b[1]-1] and counter[b[0]-1] == 1:
        counter[b[1]-1] = 0
    elif H[b[0]-1] == H[b[1]-1]:
        counter[b[0]-1] = 0
        counter[b[1]-1] = 0

print(sum(counter))

Submission status: Wrong Answer

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

# N = [6, 5]
# H = [8, 6, 9, 1, 2, 1]
# B = [[1, 3], [4, 2], [4, 3], [4, 6], [4, 6]]

counter = [1 for i in range(N[0])]

for b in B:
    if H[b[1]-1] > H[b[0]-1]:
        counter[b[1]-1] = 1
        counter[b[0]-1] = 0
    elif H[b[0]-1] > H[b[1]-1]:
        counter[b[0]-1] = 1
        counter[b[1]-1] = 0
    elif H[b[0]-1] == H[b[1]-1]:
        counter[b[0]-1] = 0
        counter[b[1]-1] = 0

print(sum(counter))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
n,m = map(int,input().split())
h_list = list(map(int,input().split()))
connect_dic = defaultdict(set)

for i in range(m):
    a,b = map(int,input().split())
    connect_dic[a].add(b)
    connect_dic[b].add(a)

count = 0
for k,v in connect_dic.items():
    if h_list[k-1]>=max([h_list[num-1] for num in v]):
        count += 1

print(count + n - len(connect_dic))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
n,m = map(int,input().split())
h_list = list(map(int,input().split()))
connect_dic = defaultdict(set)
for i in range(m):
    a,b = map(int,input().split())
    connect_dic[a].add(b)
    connect_dic[b].add(a)

count = 0
for k,v in connect_dic.items():
    if h_list[k-1]>=max([h_list[num-1] for num in v]):
        count += 1

print(count)

Submission status: Wrong Answer

Solution code:
a, b = map(float, input().split())
a = int(a)
b_int = b*100

ans = a*b_int/100
ans = int(ans)
print(ans)

Submission status: Wrong Answer

Solution code:
import collections
def f(heights,roads):
	adj = collections.defaultdict(list)
	count = 0
	for u,v in roads:
		adj[u].append(v)
		adj[v].append(u)
	for i,h in enumerate(heights):
		u = i + 1
		if h >= max([heights[v-1] for v in adj[u]] or [-1]): count +=1
	return count

n,m = map(int, raw_input().split(' '))
print f(map(int,raw_input().split(' ')), [map(int, raw_input().split(' ')) for _ in range(m)] )

Submission status: Wrong Answer

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

ans = [1] * n

for i in range(m):
    if h[pairs[i][0] - 1] < h[pairs[i][1] - 1]:
        ans[pairs[i][0] - 1] = 0
    else:
        ans[pairs[i][1] - 1] = 0      

print(sum(ans))

Submission status: Wrong Answer

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

ans = [-1] * n

for i in range(m):
    if h[pairs[i][0] - 1] < h[pairs[i][1] - 1]:
            ans[pairs[i][0] - 1] = 0
            if ans[pairs[i][1] - 1] != 0:
                ans[pairs[i][1] - 1] = 1
    else:
        if ans[pairs[i][0] - 1] != 0:
            ans[pairs[i][0] - 1] = 1
        ans[pairs[i][1] - 1] = 0      

for i in range(n):
    if ans[i] == -1:
        ans[i] = 1

print(sum(ans))

Submission status: Wrong Answer

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

ans = [-1] * n

for i in range(m):
    if h[pairs[i][0] - 1] < h[pairs[i][1] - 1]:
        ans[pairs[i][0] - 1] = 0
        ans[pairs[i][1] - 1] = 1
    else:
        ans[pairs[i][0] - 1] = 1
        ans[pairs[i][1] - 1] = 0      

for i in range(n):
    if ans[i] == -1:
        ans[i] = 1
    
print(sum(ans))

Submission status: Wrong Answer

Solution code:
N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
H = [0] + H
judge = [True] * (N + 1)
AB = []
for _ in range(M):
    ab = list(map(int, input().split()))
    AB.append(ab)

for i in range(M):
    if H[AB[i][0]] > H[AB[i][1]]:
        judge[AB[i][1]] = False
    elif H[AB[i][0]] < H[AB[i][1]]:
        judge[AB[i][0]] = False
print(judge.count(True) - 1)

Submission status: Wrong Answer

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

ans = [0] * n

for i in range(m):
    if h[pairs[i][0] - 1] < h[pairs[i][1] - 1]:
        ans[pairs[i][0] - 1] = 0
        ans[pairs[i][1] - 1] = 1
    else:
        ans[pairs[i][0] - 1] = 1
        ans[pairs[i][1] - 1] = 0      

print(sum(ans))

Submission status: Wrong Answer

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

ans = [1] * n

for i in range(m):
    if h[pairs[i][0] - 1] < h[pairs[i][1] - 1]:
        ans[pairs[i][0] - 1] = 0
        ans[pairs[i][1] - 1] = 1
    else:
        ans[pairs[i][0] - 1] = 1
        ans[pairs[i][1] - 1] = 0      

print(sum(ans))

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())
arr = list(map(int, input().split()))

ans_arr = []
dif_arr = []
for i in range(a):
    ans_arr.append(0)
    dif_arr.append(i+1)


input_arr = []
for _ in range(b):
    add_arr = list(map(int, input().split()))
    input_arr.append(add_arr)


input_arr2 = []
for i in range(b):
    input_arr2.append(input_arr[i][0])
    input_arr2.append(input_arr[i][1])
    if arr[input_arr[i][0]-1] < arr[input_arr[i][1]-1]:
        ans_arr[input_arr[i][0] - 1] = 0
        ans_arr[input_arr[i][1] - 1] = 1
    elif arr[input_arr[i][0]-1] > arr[input_arr[i][1]-1]:
        ans_arr[input_arr[i][0] - 1] = 1
        ans_arr[input_arr[i][1] - 1] = 0

A = set(input_arr2)
B = set(dif_arr)

C = list(B.difference(A))

for i in range(len(C)):
    ans_arr[C[0]-1] = 1

print(sum(ans_arr))