結果

問題 No.1285 ゴミ捨て
ユーザー toshiro_yanagitoshiro_yanagi
提出日時 2022-07-04 21:39:20
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 297 ms / 2,000 ms
コード長 557 bytes
コンパイル時間 323 ms
コンパイル使用メモリ 10,832 KB
実行使用メモリ 13,396 KB
最終ジャッジ日時 2023-08-21 06:04:58
合計ジャッジ時間 4,611 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,852 KB
testcase_01 AC 15 ms
7,916 KB
testcase_02 AC 15 ms
7,840 KB
testcase_03 AC 15 ms
7,836 KB
testcase_04 AC 15 ms
7,968 KB
testcase_05 AC 15 ms
7,896 KB
testcase_06 AC 15 ms
7,808 KB
testcase_07 AC 281 ms
13,052 KB
testcase_08 AC 25 ms
8,408 KB
testcase_09 AC 130 ms
10,356 KB
testcase_10 AC 245 ms
12,488 KB
testcase_11 AC 223 ms
12,164 KB
testcase_12 AC 170 ms
11,092 KB
testcase_13 AC 169 ms
11,056 KB
testcase_14 AC 269 ms
12,824 KB
testcase_15 AC 194 ms
11,588 KB
testcase_16 AC 66 ms
9,020 KB
testcase_17 AC 66 ms
9,060 KB
testcase_18 AC 62 ms
8,972 KB
testcase_19 AC 119 ms
10,120 KB
testcase_20 AC 58 ms
8,896 KB
testcase_21 AC 79 ms
9,244 KB
testcase_22 AC 297 ms
13,252 KB
testcase_23 AC 297 ms
13,396 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

bufio_scanner = []


def main():
    n = int(fmt_scan())
    a = reversed(sorted([int(fmt_scan()) for _ in range(n)]))

    ans = n
    d = [0, 0]
    for v in a:
        d.sort()
        for i, di in enumerate(d):
            if v <= di - 2:
                d[i] = v
                ans -= 1
                break
        else:
            d[0] = v
    print(ans)


def fmt_scan() -> str:
    sc = bufio_scanner
    if len(sc) == 0:
        for v in reversed(input().split()):
            sc.append(v)
    res = sc[-1]
    sc.pop()
    return res


main()
0