欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF851A.Arpa and a research in Mexican wave
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.
Input
The first line contains three integers n, k, t (1 ≤ n ≤ 109, 1 ≤ k ≤ n, 1 ≤ t < n + k).
Output
Print single integer: how many spectators are standing at time t.
Note
In the following a sitting spectator is represented as -, a standing spectator is represented as ^.
- At t = 0
----------
number of standing spectators = 0. - At t = 1
^---------
number of standing spectators = 1. - At t = 2
^^--------
number of standing spectators = 2. - At t = 3
^^^-------
number of standing spectators = 3. - At t = 4
^^^^------
number of standing spectators = 4. - At t = 5
^^^^^-----
number of standing spectators = 5. - At t = 6
-^^^^^----
number of standing spectators = 5. - At t = 7
--^^^^^---
number of standing spectators = 5. - At t = 8
---^^^^^--
number of standing spectators = 5. - At t = 9
----^^^^^-
number of standing spectators = 5. - At t = 10
-----^^^^^
number of standing spectators = 5. - At t = 11
------^^^^
number of standing spectators = 4. - At t = 12
-------^^^
number of standing spectators = 3. - At t = 13
--------^^
number of standing spectators = 2. - At t = 14
---------^
number of standing spectators = 1. - At t = 15
----------
number of standing spectators = 0.
Samples
10 5 3
3
10 5 7
5
10 5 12
3
在线编程 IDE
建议全屏模式获得最佳体验
键盘快捷键
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |
第 1 行,第 1 列
0 字符
-
最近自测结果
暂未运行
最近递交结果
暂无递交记录