結果

問題 No.33 アメーバがたくさん
ユーザー takakintakakin
提出日時 2020-06-24 21:30:46
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 31 ms / 5,000 ms
コード長 483 bytes
コンパイル時間 95 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-07-03 20:21:00
合計ジャッジ時間 977 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=lambda: sys.stdin.readline().rstrip()
n,d,t=map(int,input().split())
X=[int(i) for i in input().split()]
import collections
D=collections.defaultdict(list)
for x in X:
  D[x%d].append(x)
ans=0
for x in D.keys():
  A=sorted(D[x])
  prev_l=-10**20
  prev_r=-10**20
  for a in A:
    if a-d*t>prev_r+d:
      if prev_l!=prev_r:
        ans+=(prev_r-prev_l)//d+1
      prev_l=a-d*t
      prev_r=a+d*t
    else:
      prev_r=a+d*t
  ans+=(prev_r-prev_l)//d+1
print(ans)

0