Codeforces 851A Arpa and a research in Mexican wave

来源:互联网 发布:91家居设计软件 编辑:程序博客网 时间:2024/05/21 08:36

题目链接:CF-851A

挺有意思的一道题,模拟体育场上的人浪,问t时间有多少人是站立的。
直接模拟就可以,中间有一段人数是不变的,只需要考虑刚开始和最后一段时间的人数变化即可。
#define _CRT_SECURE_NO_WARNINGS#include <iostream>#include <algorithm>#include <cstdio>#include <cstring>#include <string>#include <string.h>using namespace std;int main() {int n, k, t;scanf("%d %d %d", &n, &k, &t);if (t <= k)printf("%d\n", t);else if (t <= n)printf("%d\n", k);else{int s = t - n;printf("%d\n", k - s);}return 0;}


阅读全文
0 0
原创粉丝点击