結果

問題 No.2563 色ごとのグループ
ユーザー Basin-BugBasin-Bug
提出日時 2023-12-02 15:45:53
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 408 bytes
コンパイル時間 706 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 113,320 KB
最終ジャッジ日時 2023-12-02 15:46:00
合計ジャッジ時間 6,508 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 38 ms
53,460 KB
testcase_02 AC 37 ms
53,460 KB
testcase_03 AC 36 ms
53,460 KB
testcase_04 AC 40 ms
53,460 KB
testcase_05 AC 35 ms
53,460 KB
testcase_06 AC 35 ms
53,460 KB
testcase_07 AC 35 ms
53,460 KB
testcase_08 AC 36 ms
55,612 KB
testcase_09 AC 38 ms
55,608 KB
testcase_10 AC 37 ms
55,612 KB
testcase_11 AC 39 ms
55,612 KB
testcase_12 AC 38 ms
55,612 KB
testcase_13 AC 39 ms
55,612 KB
testcase_14 AC 61 ms
71,012 KB
testcase_15 AC 59 ms
73,120 KB
testcase_16 AC 62 ms
73,116 KB
testcase_17 AC 62 ms
71,012 KB
testcase_18 AC 46 ms
64,424 KB
testcase_19 AC 70 ms
76,448 KB
testcase_20 AC 82 ms
78,088 KB
testcase_21 AC 76 ms
76,628 KB
testcase_22 AC 75 ms
76,532 KB
testcase_23 AC 79 ms
76,636 KB
testcase_24 AC 166 ms
93,852 KB
testcase_25 AC 156 ms
96,540 KB
testcase_26 AC 196 ms
110,452 KB
testcase_27 AC 214 ms
106,476 KB
testcase_28 AC 216 ms
113,320 KB
testcase_29 AC 255 ms
106,552 KB
testcase_30 AC 252 ms
106,552 KB
testcase_31 AC 253 ms
106,552 KB
testcase_32 AC 254 ms
106,552 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
権限があれば一括ダウンロードができます

ソースコード

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