結果

問題 No.1285 ゴミ捨て
ユーザー nohakai3nohakai3
提出日時 2022-07-14 18:18:01
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 254 ms / 2,000 ms
コード長 241 bytes
コンパイル時間 92 ms
コンパイル使用メモリ 10,732 KB
実行使用メモリ 12,664 KB
最終ジャッジ日時 2023-09-08 09:04:07
合計ジャッジ時間 4,614 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,936 KB
testcase_01 AC 15 ms
7,904 KB
testcase_02 AC 16 ms
7,884 KB
testcase_03 AC 16 ms
7,992 KB
testcase_04 AC 16 ms
7,908 KB
testcase_05 AC 16 ms
8,028 KB
testcase_06 AC 16 ms
7,920 KB
testcase_07 AC 242 ms
12,620 KB
testcase_08 AC 23 ms
8,288 KB
testcase_09 AC 114 ms
10,132 KB
testcase_10 AC 215 ms
12,020 KB
testcase_11 AC 212 ms
11,776 KB
testcase_12 AC 157 ms
10,812 KB
testcase_13 AC 149 ms
10,680 KB
testcase_14 AC 230 ms
12,344 KB
testcase_15 AC 170 ms
11,108 KB
testcase_16 AC 57 ms
8,908 KB
testcase_17 AC 58 ms
8,996 KB
testcase_18 AC 54 ms
8,976 KB
testcase_19 AC 103 ms
10,032 KB
testcase_20 AC 51 ms
8,792 KB
testcase_21 AC 69 ms
9,132 KB
testcase_22 AC 254 ms
12,664 KB
testcase_23 AC 253 ms
12,656 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heappush, heapreplace

n=int(input())
A=[]
for i in range(n):
    a=int(input())
    A.append(a)

A.sort()
q=[A[0]]
for a in A[1:]:
    if a<=q[0] + 1:
        heappush(q,a)
    else:
        heapreplace(q,a)

print(len(q))
0