码迷,mamicode.com
首页 > 其他好文 > 详细

Crazy Computer

时间:2019-07-20 00:01:30      阅读:118      评论:0      收藏:0      [点我收藏+]

标签:color   bool   col   freopen   turn   span   code   using   algorithm   

题目链接:http://codeforces.com/problemset/problem/716/A

 

题目大意:

把题读懂就是水题了。题目是说打下下一个字母的时候,如果和之前字母打下的时间不超过k的话,则保留前面的继续打,如果超过了,则前面的字母全部消失,只留下这一个字母。

 

哭泣。一直在读错题意!

 

 1 #include <iostream>
 2 #include <algorithm>
 3 #include <stdlib.h>
 4 #include <string>
 5 #include <string.h>
 6 #include <set>
 7 #include <queue>
 8 #include <stdbool.h>
 9 #include <map>
10 
11 using namespace std;
12 const int MAXN=100005;
13 
14 int a[MAXN];
15 
16 int main()
17 {
18 #ifndef ONLINE_JUDGE
19     freopen("../in.txt","r",stdin);
20 #endif
21     int n,c;
22     scanf("%d%d",&n,&c);
23     for (int i=0;i<n;i++)
24         cin >> a[i];
25     int cnt = 1;
26     for (int i=1;i<n;i++) {
27         if (a[i]-a[i-1]<=c)
28             cnt++;
29         else
30             cnt = 1;
31     }
32     printf("%d\n",cnt);
33     return 0;
34 }

 

Crazy Computer

标签:color   bool   col   freopen   turn   span   code   using   algorithm   

原文地址:https://www.cnblogs.com/-Ackerman/p/11216090.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!