結果

問題 No.33 アメーバがたくさん
ユーザー takakintakakin
提出日時 2020-06-24 21:30:46
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 19 ms / 5,000 ms
コード長 483 bytes
コンパイル時間 80 ms
コンパイル使用メモリ 10,716 KB
実行使用メモリ 8,624 KB
最終ジャッジ日時 2023-09-16 21:20:50
合計ジャッジ時間 928 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,464 KB
testcase_01 AC 18 ms
8,460 KB
testcase_02 AC 19 ms
8,468 KB
testcase_03 AC 19 ms
8,624 KB
testcase_04 AC 17 ms
8,508 KB
testcase_05 AC 18 ms
8,400 KB
testcase_06 AC 18 ms
8,508 KB
testcase_07 AC 17 ms
8,544 KB
testcase_08 AC 17 ms
8,560 KB
testcase_09 AC 17 ms
8,580 KB
testcase_10 AC 18 ms
8,508 KB
権限があれば一括ダウンロードができます

ソースコード

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