結果

問題 No.1686 Geschenkt
ユーザー wesoweeenwesoweeen
提出日時 2021-12-05 14:56:21
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 39 ms / 2,000 ms
コード長 480 bytes
コンパイル時間 109 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 11,392 KB
最終ジャッジ日時 2024-07-07 07:50:42
合計ジャッジ時間 1,201 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
11,392 KB
testcase_01 AC 37 ms
11,264 KB
testcase_02 AC 38 ms
11,264 KB
testcase_03 AC 37 ms
11,264 KB
testcase_04 AC 39 ms
11,264 KB
testcase_05 AC 37 ms
11,392 KB
testcase_06 AC 36 ms
11,392 KB
testcase_07 AC 36 ms
11,392 KB
testcase_08 AC 36 ms
11,392 KB
testcase_09 AC 37 ms
11,264 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