CodeForces 716A Crazy Computer
题目链接:http://codeforces.com/problemset/problem/716/A
题目大意:
输入 n c, 第二行 n 个整数,c表示时间间隔 秒。
每个整数代表是第几秒。如果本次和下一秒间隔>c 则之前的计数次数清0,否则每次输入一个数,计数++;
问最后剩几个数。
举例:
input:
6 5
1 3 8 14 19 20
output:
3
解析:
1 3 8 此时剩 3 个数,因为每次输入距离下次输入时间间隔都<5。下一次是 14 距离上一次 间隔为14-8>5 ,计数清0。
下一次 19-14<5 保留,下一次 20-19<5 保留,故此时剩下 14 19 20 。所有输出 3.
解题思路:
先输入一个数,然后for剩下的数,如果下一个数与前一个是查大于 c 则cut=0,否则cut++;最后输出 cut+1.为什么+1 读者自己思考,可参考举例解析。
AC Code:
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,c;
while(scanf("%d%d",&n,&c)!=EOF)
{
int i;
int x,x1,cut=;
scanf("%d",&x);
for(i=; i<n; i++)
{
scanf("%d",&x1);
if((x1-x)>c)
cut=;
else cut++;
x=x1;
}
printf("%d\n",cut+);
}
return ;
}
CodeForces 716A Crazy Computer的更多相关文章
- Codeforces 716A Crazy Computer 【模拟】 (Codeforces Round #372 (Div. 2))
A. Crazy Computer time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...
- Codeforces Round #372 (Div. 2) A .Crazy Computer/B. Complete the Word
Codeforces Round #372 (Div. 2) 不知不觉自己怎么变的这么水了,几百年前做A.B的水平,现在依旧停留在A.B水平.甚至B题还不会做.难道是带着一种功利性的态度患得患失?总共 ...
- Crazy Computer
ZS the Coder is coding on a crazy computer. If you don't type in a word for a cconsecutive seconds, ...
- Codeforces 498A Crazy Town
C. Crazy Town time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- Codeforces 499C:Crazy Town(计算几何)
题目链接 给出点A(x1,y1),B(x2,y2),和n条直线(ai,bi,ci,aix + biy + ci = 0),求A到B穿过多少条直线 枚举每条直线判断A.B是否在该直线两侧即可 #incl ...
- CF716A Crazy Computer 题解
Content 有一个电脑,如果过了 \(c\) 秒之后还没有任何打字符的操作,就把屏幕上面所有的字符清空.现在,给定 \(n\) 次打字符的时间 \(t_1,t_2,...,t_n\),求最后屏幕剩 ...
- Codeforces水题集合[14/未完待续]
Codeforces Round #371 (Div. 2) A. Meeting of Old Friends |B. Filya and Homework A. Meeting of Old Fr ...
- Codeforces Round #370 - #379 (Div. 2)
题意: 思路: Codeforces Round #370(Solved: 4 out of 5) A - Memory and Crow 题意:有一个序列,然后对每一个进行ai = bi - bi ...
- Codeforces Round #372 (Div. 2) A
Description ZS the Coder is coding on a crazy computer. If you don't type in a word for a c consecut ...
随机推荐
- VMWare虚拟机提供的桥接、nat和主机模式的区别
虚拟机网络模式 无论是vmware,virtual box,virtual pc等虚拟机软件,一般来说,虚拟机有三种网络模式: 1.桥接 2.NAT 3.Host-Only 哪一种网络是适合自己的虚拟 ...
- 【BZOJ 1875】【SDOI 2009】HH去散步
水啊水,最后ans别忘了%哦! #include<cstdio> #include<cstring> #include<algorithm> using names ...
- asp.net mvc 数据查询赋值到文本框中
大家做了很多文本框查询并且赋值回来 1.先是把数据对象查询结果后台,然后把对象赋值给对象在赋值回来前台页面 2.使用@html helerper 数据查询,使用 ViewContext.RouteDa ...
- 【Codeforces 722C】Destroying Array (数据结构、set)
题意 输入一个含有 n(1≤n≤100000) 个非负整数的 a 数组和一个 1-n 的排列 p 数组,求每次删除 a[p[i]] 后,最大连续子段和(不能跨越被删除的)是多少? 分析 因为都是非负整 ...
- UIView的autoresizingMask和autoresizesSubviews属性的剖析
UIVIew的autoresizingMask和autoresizesSubviews属性的剖析 autoresizingMask是为了iPad开发中横竖屏适配而降生的,他只能约束父子控件之间的关系. ...
- Python3 连接Mysql
代码: #!/usr/bin/env python # encoding: utf-8 """ @author: 侠之大者kamil @file: mysql_test. ...
- git 最基本的使用方法
1. git init ----初始化git仓库 2.git add . ----把代码添加到仓库 3.git commit -m '注释' ---commit:提交 -m:全部提交 ‘ ...
- SQL查询记录是否在另一个表中存在
1.需求 create table ta(id int);create table tb(id int);insert into ta values(1);insert into ta values( ...
- Android Studio配置指南总结
转载:http://blog.csdn.net/mynameishuangshuai/article/details/51332790 使用AndroidStudio开发APP已有半年多的时间了,从 ...
- Java中Unicode的编码和实现
Unicode的编码和实现 大概来说,Unicode编码系统可分为编码方式和实现方式两个层次. 编码方式 字符是抽象的最小文本单位.它没有固定的形状(可能是一个字形),而且没有值.“A”是一个字符,“ ...