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 ≤ n, 1 ≤ 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.

题意:自己读一读就行

解法:暗中观察

 #include<bits/stdc++.h>
using namespace std;
int main(){
int n,k,t;
cin>>n>>k>>t;
if(k>=t){
cout<<t<<endl;
}else if(t<=n){
cout<<k<<endl;
}else if(n+k<=t){
cout<<""<<endl;
}else{
cout<<k-(t-n)<<endl;
}
return ;
}

Codeforces Round #432 (Div. 2, based on IndiaHacks Final Round 2017) A的更多相关文章

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

    http://codeforces.com/contest/851/problem/D 分区间操作 #include <cstdio> #include <cstdlib> # ...

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

    A. Arpa and a research in Mexican wave time limit per test 1 second memory limit per test 256 megaby ...

  3. Codeforces Round #432 (Div. 1, based on IndiaHacks Final Round 2017) D. Tournament Construction(dp + 构造)

    题意 一个竞赛图的度数集合是由该竞赛图中每个点的出度所构成的集合. 现给定一个 \(m\) 个元素的集合,第 \(i\) 个元素是 \(a_i\) .(此处集合已经去重) 判断其是否是一个竞赛图的度数 ...

  4. 【前缀和】【枚举倍数】 Codeforces Round #432 (Div. 2, based on IndiaHacks Final Round 2017) D. Arpa and a list of numbers

    题意:给你n个数,一次操作可以选一个数delete,代价为x:或者选一个数+1,代价y.你可以进行这两种操作任意次,让你在最小的代价下,使得所有数的GCD不为1(如果全删光也视作合法). 我们从1到m ...

  5. 【推导】【暴力】Codeforces Round #432 (Div. 2, based on IndiaHacks Final Round 2017) C. Five Dimensional Points

    题意:给你五维空间内n个点,问你有多少个点不是坏点. 坏点定义:如果对于某个点A,存在点B,C,使得角BAC为锐角,那么A是坏点. 结论:如果n维空间内已经存在2*n+1个点,那么再往里面添加任意多个 ...

  6. 【推导】Codeforces Round #432 (Div. 2, based on IndiaHacks Final Round 2017) B. Arpa and an exam about geometry

    题意:给你平面上3个不同的点A,B,C,问你能否通过找到一个旋转中心,使得平面绕该点旋转任意角度后,A到原先B的位置,B到原先C的位置. 只要A,B,C构成等腰三角形,且B为上顶点.那么其外接圆圆心即 ...

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

    Arpa has found a list containing n numbers. He calls a list bad if and only if it is not empty and g ...

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

    You are given set of n points in 5-dimensional space. The points are labeled from 1 to n. No two poi ...

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

    Arpa is taking a geometry exam. Here is the last problem of the exam. You are given three points a,  ...

随机推荐

  1. BZOJ 1660 [Usaco2006 Nov]Bad Hair Day 乱发节:单调栈

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1660 题意: 有n头牛,身高分别为h[i]. 它们排成一排,面向右边.第i头牛可以看见在它 ...

  2. Centos7配置https,及多个https配置

    Centos7.2配置https,及多个https配置 1.单个https配置 检查相关依赖,如果没有就yum安装 yum install mod_ssl openssl rpm -qa| grep ...

  3. codeforces 610D D. Vika and Segments(离散化+线段树+扫描线算法)

    题目链接: D. Vika and Segments time limit per test 2 seconds memory limit per test 256 megabytes input s ...

  4. FAQrobot 聊天机器人笔记

    follow: https://github.com/ofooo/FAQrobot  这是一个简单的基于问词匹配的自动问答,获取与用户问句Q1最匹配的知识库中的问句Q2,Q2的答案就是Q1的答案. 首 ...

  5. sed根据关键字注释crontab的计划任务

    [root@linux06 ~]# crontab -e*/5 * * * * /root/time_test.sh ----------------------------------------- ...

  6. C# GUID使用总结

    全局唯一标识符(GUID,Globally Unique Identifier) What is GUID 也称作 UUID(Universally Unique IDentifier) . GUID ...

  7. win10 安装nodejs,报错there is a problem in the windows installer package

    今天重装了win10系统,开始安装各种软件,装到node的时候我崩溃了,报错there is a problem in the windows installer package··· 度娘了各种安装 ...

  8. [51nod1102]面积最大的矩形(单调栈||预处理)

    题意:求序列上某区间最小值乘区间长度的最大值. 解题关键:很早就在<挑战程序设计竞赛>中见过了,单调栈模板题,注意弹栈时如何处理后面的元素. 法一:单调栈 #include<bits ...

  9. win10 ObservableCollection 排序自动收缩问题

    ObservableCollection本身是没有排序Sort功能的,不过我们可以通过冒泡排序来实现,以下是扩展功能: public static void Sort<T>(this Ob ...

  10. 此microsoft fix it不适用于您的操作系统 解决方案

    想卸载低版本的office,下载了一个office卸载程序,但是运行时提示  此microsoft fix it不适用于您的操作系统 错误,在网上找了下解决方案,如下: 右键点击“兼容性疑难检查”,等 ...