Codeforces 851A
来源:互联网 发布:重庆大学教育网络 编辑:程序博客网 时间:2024/06/05 15:36
链接:
http://codeforces.com/contest/851/problem/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 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.
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.
题意:
有n个人,最多有k个人站起来,每秒都有一个人站起来或者是坐下,详情见题目里的note。
思路:
t小于k的时候直接输出t,t大于n的时候就是
实现:
#include <bits/stdc++.h>using namespace std;int main() {#ifndef ONLINE_JUDGE freopen("in.txt","r",stdin);#endif long long n, k, t; scanf("%lld%lld%lld", &n, &k, &t); if(t<k) return 0*printf("%lld\n", t); if(t>n) return 0*printf("%lld\n", k-t+n); return 0*printf("%lld\n", k);}
- Codeforces 851A
- CodeForces-a
- Codeforces 903A A
- Codeforces 851 A Arpa and a research in Mexican wave
- Codeforces 851A Arpa and a research in Mexican wave
- CodeForces 18A A - Triangle
- CodeForces 133A A. HQ9+
- codeforces 651A A. Joysticks
- 【Codeforces 597A】A. Divisibility
- 【 Codeforces 615A】A. Bulbs
- A. Divisibility CodeForces 597A
- codeforces 417A A. Elimination
- CodeForces 534A A. Exam
- Codeforces 851A && Round #432 Div. 2 A. Arpa and a research in Mexic
- codeforces#98 a
- codeforces#99 a
- codeforces 105 div2 A
- codeforces #121 A
- python--异常处理
- AJAX第一步:AJAX接收返回类型为text/html的字符串数据
- matlab2c使用c++实现matlab函数系列教程-abs函数
- SSH整合(配置文件)
- 圆环的颜色切换与速度控制
- Codeforces 851A
- 网易2018校招内推--整数数列
- pkg-config命令使用
- <netty权威指南>笔记-分隔符解码器处理半包问题
- JavaScript专业八级测试,你能做对几道?
- Ubuntu系统如何更改用户密码
- HTML常用标签
- easyui Combotree默认选中第一项
- JS中AOP的实现和运用