結果

問題 No.182 新規性の虜
ユーザー nanaenanae
提出日時 2016-12-31 15:23:27
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 102 ms / 5,000 ms
コード長 696 bytes
コンパイル時間 336 ms
コンパイル使用メモリ 10,736 KB
実行使用メモリ 19,484 KB
最終ジャッジ日時 2023-08-27 14:03:57
合計ジャッジ時間 2,854 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,840 KB
testcase_01 AC 16 ms
7,880 KB
testcase_02 AC 17 ms
7,888 KB
testcase_03 AC 17 ms
7,888 KB
testcase_04 AC 16 ms
7,808 KB
testcase_05 AC 16 ms
7,840 KB
testcase_06 AC 16 ms
7,808 KB
testcase_07 AC 17 ms
7,844 KB
testcase_08 AC 66 ms
13,668 KB
testcase_09 AC 102 ms
17,296 KB
testcase_10 AC 90 ms
15,980 KB
testcase_11 AC 74 ms
14,428 KB
testcase_12 AC 40 ms
11,028 KB
testcase_13 AC 16 ms
7,884 KB
testcase_14 AC 16 ms
7,896 KB
testcase_15 AC 16 ms
7,708 KB
testcase_16 AC 16 ms
7,984 KB
testcase_17 AC 16 ms
7,776 KB
testcase_18 AC 82 ms
16,476 KB
testcase_19 AC 60 ms
14,248 KB
testcase_20 AC 41 ms
11,780 KB
testcase_21 AC 92 ms
17,548 KB
testcase_22 AC 48 ms
12,740 KB
testcase_23 AC 16 ms
7,712 KB
testcase_24 AC 88 ms
19,484 KB
testcase_25 AC 59 ms
9,976 KB
testcase_26 AC 26 ms
9,356 KB
testcase_27 AC 17 ms
7,764 KB
evil01.txt AC 90 ms
18,820 KB
evil02.txt AC 87 ms
18,948 KB
権限があれば一括ダウンロードができます

ソースコード

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