ACM刷题之codeforce————Arpa and a research in Mexican wave
2017-09-05 22:19
671 查看
A. Arpa and a research in Mexican wave
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
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
output
input
output
input
output
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.
简单的规律题
分类讨论即可
下面是ac代码:
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
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.
简单的规律题
分类讨论即可
下面是ac代码:
#include<bits/stdc++.h> using namespace std; #define MID(x,y) ((x+y)>>1) #define CLR(arr,val) memset(arr,val,sizeof(arr)) #define FAST_IO ios::sync_with_stdio(false);cin.tie(0); const double PI = acos(-1.0); const int INF = 0x3f3f3f3f; const int N=2e5+7; int main() { //freopen("f:/input.txt", "r", stdin); int n,k,t; scanf("%d%d%d",&n,&k,&t); if(t<=k){ printf("%d\n",t); return 0; } if(t<=n){ printf("%d\n",k); return 0; } printf("%d\n",k-(t-n)); }
相关文章推荐
- A - Arpa and a research in Mexican wave
- Codeforces Round #432 (Div. 2) - A - Arpa and a research in Mexican wave
- Codeforces 851 A Arpa and a research in Mexican wave
- A. Arpa and a research in Mexican wave
- Codeforces 851A - Arpa and a research in Mexican wave - 水题
- 【Codeforces Round #432 (Div. 2) A】 Arpa and a research in Mexican wave
- A. Arpa and a research in Mexican wave
- 音乐频谱显示 FFT of waveIn audio signals. Free source code and programming help
- codeforce 741 B. Arpa's weak amphitheater and Mehrdad's valuable Hoses(背包 dp)
- codeforce 742 E. Arpa’s overnight party and Mehrdad’s silent entering (分食物||二分图染色+dfs)
- ACM刷题之codeforce————Nikita and string
- codeforce 742 D. Arpa's weak amphitheater and Mehrdad's valuable Hoses (分组背包+并查集))
- Codeforces 851A && Round #432 Div. 2 A. Arpa and a research in Mexic
- codeforce 851 B Arpa and an exam about geometry(思路)
- Associations in EF Code First: Part 1 – Introduction and Basic Concepts
- Checking Code Signing and Sandboxing Status in Code
- Substitute and Replace functions in PeopleCode
- codeforce 793 B Igor and his way to work
- codeforces 851 D. Arpa and a list of numbers(前缀和+bruteforce)
- Codeforces Codeforces Round #432 (Div. 2 D ) Arpa and a list of numbers