← All problemsSign in

Visible Buildings Queries

CSESRange QueriesOpen on judge ↗

There are n buildings in a row numbered 1, 2,\dots, n from left to right. You are standing to the left of the first building. You can see a building if it is taller than all buildings to its left. Your task is to process q queries: If only buildings in range [a, b] existed, how many buildings would you see? Input The first line has two integers n and q: the number of buildings and queries. The

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start