Company: JPMC SDE-2
Difficulty: easy
Count Dropped Requests A server handles client requests using a pool of available threads. The array server describes what happens in each of n consecutive seconds, in chronological order. During second i exactly one of the following happens: server[i] is a positive integer — that many new threads are created and added to the pool. server[i] = -1 — exactly one client request arrives. Threads stay in the pool until they are used. The rules for a request are: A request is served only if at least one thread is available at that moment. Serving a request consumes one thread, and that thread is destroyed. If a request arrives while the pool is empty, the request is dropped . Print the total number of requests that were dropped after all n seconds have been processed. Input Format The first line contains a single integer n , the number of elements in server . Each of the next n lines contains one integer server[i] . Output Format Print a single integer — the number of dropped requests. Const