結果

問題 No.2563 色ごとのグループ
ユーザー Basin-Bug
提出日時 2023-12-02 15:45:53
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 408 bytes
コンパイル時間 533 ms
コンパイル使用メモリ 82,340 KB
実行使用メモリ 113,696 KB
最終ジャッジ日時 2024-09-26 19:14:22
合計ジャッジ時間 7,111 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
N, M = map(int, input().split())
C = list(map(int, input().split()))
colors = defaultdict(int)
edges = defaultdict(int)

for i in range(N):
  colors[C[i]] += 1

for i in range(M):
  u, v = map(int, input().split())
  if C[u - 1] == C[v - 1]:
    edges[C[u - 1]] += 1

ans = 0
for i, j in colors.items():
  if edges[i] < j - 1:
    ans += (j - 1) - edges[i]

print(ans)

  
0