結果

問題 No.182 新規性の虜
ユーザー nanae
提出日時 2016-12-31 15:23:27
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 120 ms / 5,000 ms
コード長 696 bytes
コンパイル時間 534 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 20,280 KB
最終ジャッジ日時 2024-12-27 11:37:41
合計ジャッジ時間 3,504 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding: utf-8

N = int(input())
A = sorted([int(i) for i in input().split()])

# 初期化
ans = 0
flag = 0
pre = 0

for i in range(N):
    x = A[i]
    
    if x != pre:
        if i == (N - 1): # 末尾だけ気を付ける
            if flag == 1: # ...,97,98,99 とかだと98,99の2つをカウントする必要がある
                ans += 2
            else: # ...,97,97,99 という場合は99の1つだけカウント
                ans += 1
        else:
            if flag == 1: # 1コ前の要素が1個だけだったらカウントする
                ans += 1
            else:
                flag = 1
    else:
        flag = 0
        
    pre = x

print(ans)
0