Codeforces Round #432 (Div. 2, based on IndiaHacks Final Round 2017) A

Posted 樱花落舞

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Codeforces Round #432 (Div. 2, based on IndiaHacks Final Round 2017) A相关的知识,希望对你有一定的参考价值。

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 nkt (1 ≤ n ≤ 109, 1 ≤ k ≤ n1 ≤ t < n + k).

Output

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

Examples
input
10 5 3
output
3
input
10 5 7
output
5
input
10 5 12
output
3
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.

题意:自己读一读就行

解法:暗中观察

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 int main(){
 4     int n,k,t;
 5     cin>>n>>k>>t;
 6     if(k>=t){
 7         cout<<t<<endl;
 8     }else if(t<=n){
 9         cout<<k<<endl;
10     }else if(n+k<=t){
11         cout<<"0"<<endl;
12     }else{
13         cout<<k-(t-n)<<endl;
14     }
15     return 0;
16 }

 

以上是关于Codeforces Round #432 (Div. 2, based on IndiaHacks Final Round 2017) A的主要内容,如果未能解决你的问题,请参考以下文章

Codeforces Round #432 (Div. 2, based on IndiaHacks Final Round 2017) A

Codeforces Round #432 C

Codeforces Round #432 (Div. 2, based on IndiaHacks Final Round 2017) D

Codeforces Round#432 简要题解

D. Arpa and a list of numbers Codeforces Round #432 (Div. 2, based on IndiaHacks Final Round 2017)(示

枚举Codeforces Round #432 (Div. 2, based on IndiaHacks Final Round 2017) Div2C题