結果

問題 No.33 アメーバがたくさん
ユーザー dango
提出日時 2023-07-09 15:53:44
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 531 bytes
コンパイル時間 262 ms
コンパイル使用メモリ 82,252 KB
実行使用メモリ 68,684 KB
最終ジャッジ日時 2024-07-23 12:59:07
合計ジャッジ時間 1,734 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 9 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

from typing import List, Tuple
N, D, T = map(int, input().split())
X = list(map(int, input().split()))
amoeba: List[Tuple[int, int]] = []
for x in X:
    d = x % D
    if x < 0:
        d += D
    amoeba.append((x, d))
amoeba.sort(key=lambda it: (it[1], it[0]))
ans = 0
for i, a in enumerate(amoeba):
    if i == 0 or amoeba[i - 1][1] != a[1]:
        ans += T
    else:
        ans += min((a[0] - amoeba[i - 1][0]) // D - 1, T * 2)
    if i == len(amoeba) - 1 or amoeba[i + 1][1] != a[1]:
        ans += T
    ans += 1
print(ans)
0