- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Find the number of spectators standing in the stadium at time t in Python

There are n number of spectators in the stadium, and they are labeled from 1 to n. Now follow these cases −

At time t

_{1}, the first spectator stands.At time t

_{2}, the second spectator stands.…

At time t

_{k}, the k-th spectator stands.At time t

_{k + 1}, the (k + 1)-th spectator stands and the first spectator sits.At time t

_{k + 2}, the (k + 2)-th spectator stands and the second spectator sits.…

At time t

_{n}, the n-th spectator stands and the (n – k)-th spectator sits.At time t

_{n + 1}, the (n + 1 – k)-th spectator sits.…

At time t

_{n + k}, the n-th spectator sits.

So, if the input is like n = 11, k = 6, t = 4, then the output will be 4 as at time t1, 1st spectator stands, then at time t2, 2nd spectator stands after that at time t3, 3rd spectator stands, and finally at time t4, 4th spectator stands. In this way the result is 4 as there are 4 spectators standing in total.

To solve this, we will follow these steps −

if t <= k, then

return t

otherwise when t <= n, then

return k

otherwise,

res := t - n

res := k - res

return res

## Example

Let us see the following implementation to get better understanding −

def how_many_stand(n, k, t) : if (t <= k) : return t elif (t <= n) : return k else : res = t - n res = k - res return res n = 11 k = 6 t = 4 print(how_many_stand(n, k, t))

## Input

11, 6, 4

## Output

4

- Related Questions & Answers
- C++ code to number of standing spectators at time t
- Find the arrangement of queue at given time in C++
- Program to find expected growth of virus after time t in Python
- Find the number of consecutive zero at the end after multiplying n numbers in Python
- Find the probability of a state at a given time in a Markov chain - Set 1 in Python
- C++ Program to find opponent in a circular standing of persons
- Find the Duplicate Number in Python
- Find the City With the Smallest Number of Neighbors at a Threshold Distance in C++
- Find the maximum number of composite summands of a number in Python
- Find the time which is palindromic and comes after the given time in Python
- How to find the power of t test in R?
- How to import Python modules by default at the time of program starts?
- Find the sum of digits of a number at even and odd places in C++
- Program to find number of bit 1 in the given number in Python
- Multiple data input at the same time in MySQL?