結果

問題 No.33 アメーバがたくさん
ユーザー szkhtsszkhts
提出日時 2021-07-14 10:11:36
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 21 ms / 5,000 ms
コード長 487 bytes
コンパイル時間 82 ms
コンパイル使用メモリ 10,908 KB
実行使用メモリ 8,664 KB
最終ジャッジ日時 2023-09-16 07:44:23
合計ジャッジ時間 1,067 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
8,468 KB
testcase_01 AC 19 ms
8,448 KB
testcase_02 AC 19 ms
8,504 KB
testcase_03 AC 19 ms
8,484 KB
testcase_04 AC 19 ms
8,468 KB
testcase_05 AC 19 ms
8,468 KB
testcase_06 AC 18 ms
8,544 KB
testcase_07 AC 18 ms
8,548 KB
testcase_08 AC 19 ms
8,612 KB
testcase_09 AC 19 ms
8,664 KB
testcase_10 AC 19 ms
8,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
N, D, T = map(int, input().split())
X = list(map(int, input().split()))

d = defaultdict(list)
for x in X:
    d[x % D].append(x)

ans = 0
for pos in d.values():
    pos.sort()
    L = pos[0] - D * T
    R = pos[0] + D * T
    for p in pos[1:]:
        l = p - D * T
        r = p + D * T
        if l <= R:
            R = r
        else:
            ans += (R - L) // D + 1
            L = l
            R = r
    ans += (R - L) // D + 1

print(ans)
0