![](https://csoahelp.com/wp-content/uploads/2024/07/image-26-987x1024.png)
1. Question 1
A supermarket has many customers entering and exiting at various points. They want to keep track of customers and get notifications when a customer leaves the store.
There are a number of checkout lines, where customers with baskets of items queue to pay and exit the store. Individual checkout lines and customers are assigned numerical IDs.
As happens in life, sometimes customers want to add more items to their baskets and sometimes they realize that they don't need certain items they picked up earlier and remove them from the basket.
To enforce checkout priorities a few rules have been implemented in the supermarket:
- A customer cannot switch the lines before exit once they join a given checkout line.
- If a customer increases their items to purchase, they must go to the back of the same line.
- If a customer removes items from their basket, they will keep their position in the line (or leave the store if they don't have any more items).
A customer will leave the supermarket as soon as they have no items left to checkout. Note that the lines with smaller IDs are closer to the exit, so if two customers pass the checkout line at the same time, the one closer to the exit would leave the store first.
![](https://csoahelp.com/wp-content/uploads/2024/07/image-28-1024x566.png)
Problem Statement
You will receive the stream of N instructions. Each instruction can be one of the following:
- CustomerEnter id x y
A customer with IDid
enters the store withx
items and joins the liney
. - CustomerExit id
A customer with IDid
exits the store. - LineService y
Process one customer from the liney
.
Write a program to simulate the operations and generate the appropriate output for each step based on the instructions provided.
2. Question 2
We have a huge trading system at Optiver, running 10,000+ instances of binaries in production performing unique functions. Processes often have dependencies on other processes to input data from various sources and fetch parameters configured in files and databases. Every week we need to start all these processes and also stop them in the correct order. The longer these processes run, the more money we make, so we want to schedule them to run for as long as possible. Scheduling these processes to run correctly and at the correct time is a complex task, which we want you to solve for us.
Problem Statement
In this problem, you will be given a list of processes, each with a unique ID PID, a start time S - which is the earliest the process can start, and an end time E - which is the latest the process can end. You will also be given a list of inter-process dependencies, PID1 -> PID2, indicating that PID1 must start strictly before PID2 can start, and PID2 must end strictly before PID1 can end.
Time for the week is divided into integer time units that start from 1 and go up to 10^6 (inclusive).
The scheduler can only schedule processes to start or stop at the start of a time unit, for example at 1, 2, 1000, 999999 but not at 1.5, 7001, etc.
Class Description
Your task is to implement the Scheduler
class which has a constructor and a PrintSchedule
method.
The class constructor has the following parameters:
processes[0, ..., N-1]
: an array of start-time and end-time pairs
![](https://csoahelp.com/wp-content/uploads/2024/07/image-27-1024x549.png)
With our OA writing service, our Optiver company's OA perfectly achieved a full score. If you also need OA assistance, please contact us.
如果你需要OA代写,请联系我们, 确保满分。
![](https://csoahelp.com/wp-content/uploads/2024/03/image-28.png)