結果

問題 No.1285 ゴミ捨て
ユーザー neterukunneterukun
提出日時 2020-11-13 21:31:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 127 ms / 2,000 ms
コード長 349 bytes
コンパイル時間 207 ms
コンパイル使用メモリ 81,992 KB
実行使用メモリ 77,740 KB
最終ジャッジ日時 2024-05-06 14:27:05
合計ジャッジ時間 3,175 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,352 KB
testcase_01 AC 39 ms
52,664 KB
testcase_02 AC 39 ms
52,988 KB
testcase_03 AC 40 ms
52,480 KB
testcase_04 AC 40 ms
52,352 KB
testcase_05 AC 42 ms
52,736 KB
testcase_06 AC 41 ms
52,992 KB
testcase_07 AC 124 ms
77,696 KB
testcase_08 AC 69 ms
68,992 KB
testcase_09 AC 98 ms
76,888 KB
testcase_10 AC 118 ms
77,440 KB
testcase_11 AC 115 ms
77,636 KB
testcase_12 AC 105 ms
77,232 KB
testcase_13 AC 106 ms
77,440 KB
testcase_14 AC 123 ms
77,568 KB
testcase_15 AC 110 ms
77,056 KB
testcase_16 AC 79 ms
76,416 KB
testcase_17 AC 79 ms
76,232 KB
testcase_18 AC 79 ms
76,208 KB
testcase_19 AC 93 ms
76,828 KB
testcase_20 AC 77 ms
76,220 KB
testcase_21 AC 85 ms
76,416 KB
testcase_22 AC 127 ms
77,584 KB
testcase_23 AC 126 ms
77,740 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq


n = int(input())
a = [int(input()) for i in range(n)]


a.sort()
hq = []
for i in range(n):
    if not hq:
        heapq.heappush(hq, a[i])
    else:
        top = hq[0]
        if abs(top - a[i]) > 1:
            heapq.heappop(hq)
            heapq.heappush(hq, a[i])
        else:
            heapq.heappush(hq, a[i])
print(len(hq))
0