Codeforces Round 432 (Div. 2, based on IndiaHacks Final Round 2017)
A
Arpa and a research in Mexican wave
Codeforces
800
原题
←B →
翻译中…

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* ≤ 10^{9}$, $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$ ---------- image number of standing spectators = 0.
  • At $*t* = 1$ ^--------- image number of standing spectators = 1.
  • At $*t* = 2$ ^^-------- image number of standing spectators = 2.
  • At $*t* = 3$ ^^^------- image number of standing spectators = 3.
  • At $*t* = 4$ ^^^^------ image number of standing spectators = 4.
  • At $*t* = 5$ ^^^^^----- image number of standing spectators = 5.
  • At $*t* = 6$ -^^^^^---- image number of standing spectators = 5.
  • At $*t* = 7$ --^^^^^--- image number of standing spectators = 5.
  • At $*t* = 8$ ---^^^^^-- image number of standing spectators = 5.
  • At $*t* = 9$ ----^^^^^- image number of standing spectators = 5.
  • At $*t* = 10$ -----^^^^^ image number of standing spectators = 5.
  • At $*t* = 11$ ------^^^^ image number of standing spectators = 4.
  • At $*t* = 12$ -------^^^ image number of standing spectators = 3.
  • At $*t* = 13$ --------^^ image number of standing spectators = 2.
  • At $*t* = 14$ ---------^ image number of standing spectators = 1.
  • At $*t* = 15$ ---------- image number of standing spectators = 0.
翻译中…

样例

Input #1
10 5 3
Output #1
3
InputCopy OutputCopy
Input #2
10 5 7
Output #2
5
InputCopy OutputCopy
Input #3
10 5 12
Output #3
3
InputCopy OutputCopy
题目信息
题号
851A
时间限制
1 s
内存限制
256 MB
标签
模拟
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。