結果
問題 | No.33 アメーバがたくさん |
ユーザー |
![]() |
提出日時 | 2025-03-20 21:06:21 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 43 ms / 5,000 ms |
コード長 | 951 bytes |
コンパイル時間 | 160 ms |
コンパイル使用メモリ | 82,476 KB |
実行使用メモリ | 55,248 KB |
最終ジャッジ日時 | 2025-03-20 21:06:29 |
合計ジャッジ時間 | 1,235 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 11 |
ソースコード
n, D, T = map(int, input().split()) xs = list(map(int, input().split())) from collections import defaultdict groups = defaultdict(list) for x in xs: r = x % D start = x - T * D end = x + T * D groups[r].append((start, end)) ans = 0 for r in groups: intervals = groups[r] if not intervals: continue # Sort intervals by their start value intervals.sort() merged = [] current_start, current_end = intervals[0] for s, e in intervals[1:]: if s <= current_end: # Merge the intervals current_end = max(current_end, e) else: merged.append((current_start, current_end)) current_start, current_end = s, e # Add the last merged interval merged.append((current_start, current_end)) # Calculate the number of elements in each merged interval for s, e in merged: count = (e - s) // D + 1 ans += count print(ans)