测评会员优惠活动进行中 · 开通 VIP,有效期内测评不限次 VIP 优惠中 · 测评不限次 立即查看

A11073. Arpa and a research in Mexican wave

编程题 普及/提高-

题目描述

Arpa is researching the Mexican wave.

There are $n$ spectators in the stadium, labeled from $1$ to $n$ . They start the Mexican wave at time $0$ .

- At time $1$ , the first spectator stands.
- At time $2$ , the second spectator stands.
- $...$
- At time $k$ , the $k$ -th spectator stands.
- At time $k+1$ , the $(k+1)$ -th spectator stands and the first spectator sits.
- At time $k+2$ , the $(k+2)$ -th spectator stands and the second spectator sits.
- $...$
- At time $n$ , the $n$ -th spectator stands and the $(n-k)$ -th spectator sits.
- At time $n+1$ , the $(n+1-k)$ -th spectator sits.
- $...$
- At time $n+k$ , the $n$ -th spectator sits.

Arpa wants to know how many spectators are standing at time $t$ .

输入格式

The first line contains three integers $n$ , $k$ , $t$ ( $1<=n<=10^{9}$ , $1<=k<=n$ , $1<=t<n+k$ ).

输出格式

Print single integer: how many spectators are standing at time $t$ .

输入输出样例

输入 #1
10 5 3
输出 #1
3
输入 #2
10 5 7
输出 #2
5
输入 #3
10 5 12
输出 #3
3

说明/提示

In the following a sitting spectator is represented as -, a standing spectator is represented as ^.

- At $t=0 $ ---------- ![](/uploads/acgo/image/1c44b1044704e13b_9b05427edf62.jpeg) number of standing spectators = 0.
- At $t=1 $ ^--------- ![](/uploads/acgo/image/1c44b1044704e13b_9b05427edf62.jpeg) number of standing spectators = 1.
- At $t=2 $ ^^-------- ![](/uploads/acgo/image/1c44b1044704e13b_9b05427edf62.jpeg) number of standing spectators = 2.
- At $t=3 $ ^^^------- ![](/uploads/acgo/image/1c44b1044704e13b_9b05427edf62.jpeg) number of standing spectators = 3.
- At $t=4 $ ^^^^------ ![](/uploads/acgo/image/1c44b1044704e13b_9b05427edf62.jpeg) number of standing spectators = 4.
- At $t=5 $ ^^^^^----- ![](/uploads/acgo/image/1c44b1044704e13b_9b05427edf62.jpeg) number of standing spectators = 5.
- At $t=6 $ -^^^^^---- ![](/uploads/acgo/image/1c44b1044704e13b_9b05427edf62.jpeg) number of standing spectators = 5.
- At $t=7 $ --^^^^^--- ![](/uploads/acgo/image/1c44b1044704e13b_9b05427edf62.jpeg) number of standing spectators = 5.
- At $t=8 $ ---^^^^^-- ![](/uploads/acgo/image/1c44b1044704e13b_9b05427edf62.jpeg) number of standing spectators = 5.
- At $t=9 $ ----^^^^^- ![](/uploads/acgo/image/1c44b1044704e13b_9b05427edf62.jpeg) number of standing spectators = 5.
- At $t=10$ -----^^^^^ ![](/uploads/acgo/image/1c44b1044704e13b_9b05427edf62.jpeg) number of standing spectators = 5.
- At $t=11$ ------^^^^ ![](/uploads/acgo/image/1c44b1044704e13b_9b05427edf62.jpeg) number of standing spectators = 4.
- At $t=12$ -------^^^ ![](/uploads/acgo/image/1c44b1044704e13b_9b05427edf62.jpeg) number of standing spectators = 3.
- At $t=13$ --------^^ ![](/uploads/acgo/image/1c44b1044704e13b_9b05427edf62.jpeg) number of standing spectators = 2.
- At $t=14$ ---------^ ![](/uploads/acgo/image/1c44b1044704e13b_9b05427edf62.jpeg) number of standing spectators = 1.
- At $t=15$ ---------- ![](/uploads/acgo/image/1c44b1044704e13b_9b05427edf62.jpeg) number of standing spectators = 0.
上一题 去做题 下一题