結果
問題 | No.2563 色ごとのグループ |
ユーザー |
|
提出日時 | 2023-12-02 15:02:08 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 789 bytes |
コンパイル時間 | 287 ms |
コンパイル使用メモリ | 82,564 KB |
実行使用メモリ | 114,916 KB |
最終ジャッジ日時 | 2024-09-26 17:56:10 |
合計ジャッジ時間 | 5,245 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 WA * 5 |
ソースコード
import sys,math #if len(sys.argv)==2:sys.stdin=open(sys.argv[1]) from collections import defaultdict,deque from itertools import combinations,permutations,accumulate,product from bisect import bisect,bisect_left,bisect_right from heapq import heappop,heappush,heapify #from sortedcontainers import SortedList,SortedSet def input(): return sys.stdin.readline().rstrip() def ii(): return int(input()) def ms(): return map(int, input().split()) def li(): return list(map(int,input().split())) #//////////////////////////////////// N,M = ms() C = li() ans = 0 gro = defaultdict(list) for i in range(N): gro[C[i]].append(i+1) cnt = defaultdict(int) for _ in range(M): u,v = ms() if C[u-1]==C[v-1]: cnt[C[u-1]] += 1 for c in gro.keys(): ans += max(len(gro[c])-cnt[c]-1,0) print(ans)