Q ← 線分の列 for segment in Q: b ← segment.begin.x # 始点のx座標 e ← segment.end.x # 終点のx座標 A[b]++ A[e]-- for i ← 1 to N-1: A[i] ← A[i] + A[i-1]