結果

問題 No.1686 Geschenkt
ユーザー wesoweeenwesoweeen
提出日時 2021-12-05 14:56:21
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 33 ms / 2,000 ms
コード長 480 bytes
コンパイル時間 175 ms
コンパイル使用メモリ 10,656 KB
実行使用メモリ 9,820 KB
最終ジャッジ日時 2023-09-21 14:02:16
合計ジャッジ時間 1,771 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
9,708 KB
testcase_01 AC 31 ms
9,716 KB
testcase_02 AC 31 ms
9,820 KB
testcase_03 AC 32 ms
9,820 KB
testcase_04 AC 31 ms
9,716 KB
testcase_05 AC 33 ms
9,632 KB
testcase_06 AC 31 ms
9,768 KB
testcase_07 AC 31 ms
9,764 KB
testcase_08 AC 32 ms
9,716 KB
testcase_09 AC 32 ms
9,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from typing import List


ANSWERS = []
N = int(input())
input_list = input().split()
input_list = sorted([int(n) for n in input_list])


def geschenkt_rule(pair: List) -> bool:
    return pair[1] - pair[0] != 1


def main():
    ANSWERS.append(input_list[0])
    for n in range(1, N):
        pair: List = [input_list[n - 1], input_list[n]]
        if geschenkt_rule(pair):
            ANSWERS.append(input_list[n])

    print(sum(ANSWERS))


if __name__ == "__main__":
    main()
0