0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

ABC206 C - Swappable から学んだ

Posted at

abc206_1.png
abc206_2.png
abc206_3.png

うーん。分からんので回答を見た。

なるほど。NG を数えるか。
勉強になりました。

abc206c.py
N = int(input())
A = list(map(int,input().split()))
dic = {}

for i in range(N):
    if A[i] not in dic:
        dic[A[i]] = 0
    dic[A[i]] += 1

num = 0
for i in dic.keys():
    if dic[i] > 1:
        num += ( dic[i]*(dic[i]-1) )//2

print( (N*(N-1))//2 - num )
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?