Draft saved on this device
▤ Description
ConcurrencyEasy
Determine Whether A Barrier Can Release
A reusable barrier requires P arrivals per generation.
A reusable barrier requires P arrivals per generation. Read N ARRIVE events and print RELEASE each time the count reaches P, then reset the arrival count to zero for the next generation. At the end print REMAINING x showing how many arrivals belong to the unfinished generation.
Input format
First line P N; next N lines are the word ARRIVE.
Output format
Print each RELEASE on its own line, followed by REMAINING x.
Examples
Example 1
Input
3 7 ARRIVE ARRIVE ARRIVE ARRIVE ARRIVE ARRIVE ARRIVE
Expected output
RELEASE RELEASE REMAINING 1
Constraints
- 1 ≤ P ≤ 100000
- 0 ≤ N ≤ 100000
Related concepts
This early-access exercise uses standard input/output. More advanced concurrency challenges will use specialized class interfaces, instrumentation, and stress tests once the judging infrastructure is ready.
⌘ Code
Loading Monaco C++ editor…
Checking judge...
Checking whether the external C++ judge is available.
⌁ Test cases & resultsPublic samples: 1
Input
3 7 ARRIVE ARRIVE ARRIVE ARRIVE ARRIVE ARRIVE ARRIVE
Expected output
RELEASE RELEASE REMAINING 1