CF851A.Arpa and a research in Mexican wave

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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.

Arpa 正在研究墨西哥人浪。

体育场中共有 nn 名观众,编号从 11 到 nn。他们于时刻 00 开始进行墨西哥人浪:

  • 在时刻 11,第 11 名观众起立;
  • 在时刻 22,第 22 名观众起立;
  • …
  • 在时刻 kk,第 kk 名观众起立;
  • 在时刻 k+1k+1,第 k+1k+1 名观众起立,同时第 11 名观众坐下;
  • 在时刻 k+2k+2,第 k+2k+2 名观众起立,同时第 22 名观众坐下;
  • …
  • 在时刻 nn,第 nn 名观众起立,同时第 n−kn-k 名观众坐下;
  • 在时刻 n+1n+1,第 n+1−kn+1-k 名观众坐下;
  • …
  • 在时刻 n+kn+k,第 nn 名观众坐下。

Arpa 想知道:在时刻 tt,有多少名观众处于站立状态?

输入格式

The first line contains three integers n, k, t (1 ≤ n ≤ 109, 1 ≤ k ≤ n, 1 ≤ t < n + k).

第一行包含三个整数 nn、kk、tt(1 ≤ n ≤ 1091 \leq n \leq 10^9,1 ≤ k ≤ n1 \leq k \leq n,1 ≤ t < n + k1 \leq t < n + k)。

输出格式

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

输出一个整数:在时刻 tt 有多少名观众站立着。

输入输出样例

  • 输入#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  ---------- 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.

以下用 - 表示坐着的观众,用 ^ 表示站着的观众。

  • 在 t=0t = 0 时:---------- ,站立观众人数 = 0。
  • 在 t=1t = 1 时:^--------- ,站立观众人数 = 1。
  • 在 t=2t = 2 时:^^-------- ,站立观众人数 = 2。
  • 在 t=3t = 3 时:^^^------- ,站立观众人数 = 3。
  • 在 t=4t = 4 时:^^^^------ ,站立观众人数 = 4。
  • 在 t=5t = 5 时:^^^^^----- ,站立观众人数 = 5。
  • 在 t=6t = 6 时:-^^^^^---- ,站立观众人数 = 5。
  • 在 t=7t = 7 时:--^^^^^--- ,站立观众人数 = 5。
  • 在 t=8t = 8 时:---^^^^^-- ,站立观众人数 = 5。
  • 在 t=9t = 9 时:----^^^^^- ,站立观众人数 = 5。
  • 在 t=10t = 10 时:-----^^^^^ ,站立观众人数 = 5。
  • 在 t=11t = 11 时:------^^^^ ,站立观众人数 = 4。
  • 在 t=12t = 12 时:-------^^^ ,站立观众人数 = 3。
  • 在 t=13t = 13 时:--------^^ ,站立观众人数 = 2。
  • 在 t=14t = 14 时:---------^ ,站立观众人数 = 1。
  • 在 t=15t = 15 时:---------- ,站立观众人数 = 0。

输入解题思路,AI测评打分。不知道怎么写?

首页