# This content is archived!

For the 2018-2019 school year, we have switched to using the WLMOJ judge for all MCPT related content. This is an archive of our old website and will not be updated.

# Introduction

The following is a diagram of a queue. It is depicted as a linear structure. The first element is called the front. It is the next element to be removed. Conversely, the last element is called the back. It is the most recently inserted element.

Elements may only be inserted to the back and removed from the front.

# Example

To understand how a queue might be used to solve programming problems, letâ€™s solve a simple problem:

There are $N$ customers waiting in line, each wanting to buy a certain amount of bread slices. $Q$ events occur, where each one is one of two types:

Type 1: A customer goes to the back of the line, with a certain amount of bread slices.

Type 2: The customer at the front of the link leaves the line without purchasing any bread.

Finally, after all $Q$ events are over, we can simply sum up all the bread slices held by customers remaining in the line, as shown below: