CF Bear and Game
2016-05-28 12:04
274 查看
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 100
int 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;
else
break;
}
if(ans>90)
ans=90;
printf("%d\n",ans);
}
return 0;
}
/*********************************测试数据*********************************
**************************************************************************/
错误代码(没找到bug):
/*=============================AC情况===============================*/
/*题目网址: */
/*时间: */
/*心得: 看得懂英语,知道题目的题意很重要 */
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define G 100
int 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;
}
/*********************************测试数据*********************************
**************************************************************************/
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 100
int 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;
else
break;
}
if(ans>90)
ans=90;
printf("%d\n",ans);
}
return 0;
}
/*********************************测试数据*********************************
**************************************************************************/
错误代码(没找到bug):
/*=============================AC情况===============================*/
/*题目网址: */
/*时间: */
/*心得: 看得懂英语,知道题目的题意很重要 */
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define G 100
int 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;
}
/*********************************测试数据*********************************
**************************************************************************/
相关文章推荐
- 数组的基础知识
- 【LeetCode】103. Binary Tree Zigzag Level Order Traversal 解题报告
- Hibernate包及相关工具包下载地址
- Android进阶专题九:电池续航
- poj 1860 汇率2
- tomcat常见错误及解决方案
- SSH输入错误Action
- Android SlidingMenu 使用
- Android中的事件分发
- iOS开发之手势识别汇总
- 【持续更新中……】好玩的网站
- symfony 使用原始sql
- new Option及用法
- 微视图像(microview)gige相机开发手记(1)
- php函数的创建,以及引用传递和值传递的介绍!
- 使用IDEA开发Spark应用
- Android进阶专题八:性能评估
- Caffe学习(3):训练自己的数据
- github服务器挂了
- 直接双击启动tomcat中的startup.bat闪退原因及解决方法