← All problemsSign in

Collecting Numbers Distribution

CSESCounting ProblemsOpen on judge ↗

You are given an array that contains each number between 1 \dots n exactly once. You collect the numbers in increasing order from 1 to n. On each round, you traverse the array from left to right and collect as many consecutive numbers as possible, starting from the smallest number that has not been collected yet. Your task is to determine, for each k=1,2,\dots,n, the number of arrays that require

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