結果
問題 | 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 defaultdictgroups = defaultdict(list)for x in xs:r = x % Dstart = x - T * Dend = x + T * Dgroups[r].append((start, end))ans = 0for r in groups:intervals = groups[r]if not intervals:continue# Sort intervals by their start valueintervals.sort()merged = []current_start, current_end = intervals[0]for s, e in intervals[1:]:if s <= current_end:# Merge the intervalscurrent_end = max(current_end, e)else:merged.append((current_start, current_end))current_start, current_end = s, e# Add the last merged intervalmerged.append((current_start, current_end))# Calculate the number of elements in each merged intervalfor s, e in merged:count = (e - s) // D + 1ans += countprint(ans)