CF Bear and Game
来源:互联网 发布:视频播放器 for mac 编辑:程序博客网 时间:2024/04/29 13:44
Bear and Game
Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u
Submit Status
Description
BearLimak likes watching sports on TV. He is going to watch a game today. The gamelasts 90 minutes and there are no breaks.
Eachminute can be either interesting or boring. If 15 consecutiveminutes are boring then Limak immediately turns TV off.
Youknow that there will be n interestingminutes t1, t2, ..., tn.Your task is to calculate for how many minutes Limak will watch the game.
描述
熊Limak喜欢看电视上的体育节目。他今天去看一场比赛。游戏持续90分钟,没有休息。
每分钟可以有趣或无聊。如果连续15分钟是无聊的,然后Limak立即把电视关掉。
你知道会有n个有趣的时间点,时间点分别是t1,t2,…,tn。你的任务是计算有多少分钟Limak将观看比赛。
输入
输入的第一行包含一个整数n(1≤n≤90)-有趣的分钟数。
第二行包含n个整数t1,t2,…tn(1≤t1< t2 <…tn≤90),增加的顺序。
输出
打印的数量分钟Limak将观看比赛。
Input
Thefirst line of the input contains one integer n (1 ≤ n ≤ 90) —the number of interesting minutes.
Thesecond line contains n integers t1, t2, ..., tn (1 ≤ t1 < t2 < ... tn ≤ 90),given in the increasing order.
Output
Printthe number of minutes Limak will watch the game.
Sample Input
Input
3
7 20 88
Output
35
Input
9
16 20 30 40 50 60 70 80 90
Output
15
Input
9
15 20 30 40 50 60 70 80 90
Output
90
题意:统计看电视的最多时间,如果无聊的时间间隔>15就不看电视,敲代码去。
代码如下:
/*=============================AC情况===============================*//*题目网址: *//*时间: *//*心得: 看得懂英语,知道题目的题意很重要 */#include<stdio.h>#include<stdlib.h>#include<string.h>#define G 100int main() {int n,t[G],ans;while(scanf("%d",&n)!=EOF) {for(int j=1; j<=n; j++)scanf("%d",&t[j]);ans=15;for (int j=1 ; j<=n; j++) {if (t[j] <= ans)ans = t[j] + 15;elsebreak;}if(ans>90)ans=90;printf("%d\n",ans);}return 0;}/*********************************测试数据***********************************************************************************************************/
错误代码(没找到bug):
/*=============================AC情况===============================*//*题目网址: *//*时间: *//*心得: 看得懂英语,知道题目的题意很重要 */#include<stdio.h>#include<stdlib.h>#include<string.h>#define G 100int main() {int n,t[G],ans;while(scanf("%d",&n)!=EOF) {t[0]=0;//兴致勃勃的去看比赛 for(int j=1; j<n+1; j++)scanf("%d",&t[j]);/*if(t[1]>15) {printf("15\n");continue;}*/ans=0;for(int j=0; j<n; j++) {if(t[j+1]-t[j]<=15)//有趣的时间点持续更新中 ans=t[j+1];else {ans=ans+15;break;}}if(ans>90)ans=90;printf("%d\n",ans);}return 0;}/*********************************测试数据***********************************************************************************************************/
- CF Bear and Game
- CF #351 A. Bear and Game(简单题)
- A. Bear and Game
- 【codeforces】-#351A--Bear and Game(第一次cf,错到哭,还是有点开心的,嘿嘿)
- CF 226 DIV2 B. Bear and Strings
- CF 573A(Bear and Poker-GCD)
- CF#318-Bear and Elections-贪心暴力
- CF 653B. Bear and Compressing
- cf 653B Bear and Compressing
- CF 685A Bear and Reverse Radewoosh
- CF Bear and Tree Jumps树形DP
- codeforcs 351 A. Bear and Game
- CodeForces 673A Bear and Game
- CodeForces 673 A Bear and Game
- CodeForces 673A Bear and Game
- 【CodeForces】[673A]Bear and Game
- CodeForces 673 A Bear and Game
- CodeForces 673A Bear and Game
- 数据结构—二叉树练习—递归
- Android进阶专题七:多核处理器优化
- 《虚无的十字架》---作者东野圭吾 读后感
- html中的语义相关元素介绍
- 数组的基础知识
- CF Bear and Game
- 修改mysql的用户的密码
- PHP中字符安全过滤函数使用小结
- 1022. D进制的A+B (20)
- 2016sdau课程练习专题三 1004
- github服务器挂了
- Caffe学习(3):训练自己的数据
- Android进阶专题八:性能评估
- php函数的创建,以及引用传递和值传递的介绍!