题意:给定 n 个数,问你连续的最长的序列是几个。

析:从头扫一遍即可。

代码如下:

#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
using namespace std ;
typedef long long LL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const double inf = 0x3f3f3f3f3f3f3f;
const double eps = 1e-8;
const int maxn = 1e5 + 5;
const int dr[] = {0, 0, -1, 1};
const int dc[] = {-1, 1, 0, 0};
int n, m;
inline bool is_in(int r, int c){
return r >= 0 && r < n && c >= 0 && c < m;
}
int a[maxn]; int main(){
cin >> n;
for(int i = 1; i <= n; ++i) scanf("%d", &a[i]);
int ans = 1;
int s = 0, e = 2;
int cnt = 0;
a[0] = 0;
while(e <= n){
cnt = 1;
while(e <= n && a[e] > a[e-1]){ ++cnt; ++e; }
ans = max(ans, cnt);
++e;
} cout << ans << endl;
return 0;
}

CodeForces 702 A Maximum Increase (贪心,高效算法)的更多相关文章

  1. codeforces 702A A. Maximum Increase(水题)

    题目链接: A. Maximum Increase time limit per test 1 second memory limit per test 256 megabytes input sta ...

  2. Codeforces Educational Codeforces Round 15 A. Maximum Increase

    A. Maximum Increase time limit per test 1 second memory limit per test 256 megabytes input standard ...

  3. 深入N皇后问题的两个最高效算法的详解 分类: C/C++ 2014-11-08 17:22 117人阅读 评论(0) 收藏

    N皇后问题是一个经典的问题,在一个N*N的棋盘上放置N个皇后,每行一个并使其不能互相攻击(同一行.同一列.同一斜线上的皇后都会自动攻击). 一. 求解N皇后问题是算法中回溯法应用的一个经典案例 回溯算 ...

  4. cf702A Maximum Increase

    A. Maximum Increase time limit per test 1 second memory limit per test 256 megabytes input standard ...

  5. codeforces Gym 100338E Numbers (贪心,实现)

    题目:http://codeforces.com/gym/100338/attachments 贪心,每次枚举10的i次幂,除k后取余数r在用k-r补在10的幂上作为候选答案. #include< ...

  6. [Codeforces 1214A]Optimal Currency Exchange(贪心)

    [Codeforces 1214A]Optimal Currency Exchange(贪心) 题面 题面较长,略 分析 这个A题稍微有点思维难度,比赛的时候被孙了一下 贪心的思路是,我们换面值越小的 ...

  7. CVPR2020论文介绍: 3D 目标检测高效算法

    CVPR2020论文介绍: 3D 目标检测高效算法 CVPR 2020: Structure Aware Single-Stage 3D Object Detection from Point Clo ...

  8. Codeforces - 702A - Maximum Increase - 简单dp

    DP的学习计划,刷 https://codeforces.com/problemset?order=BY_RATING_ASC&tags=dp 遇到了这道题 https://codeforce ...

  9. Codeforces 702A Maximum Increase(dp)

    题目链接:http://codeforces.com/problemset/problem/702/A 题意: 给你N个数,a[0], a[1], a[2], ....., a[n-1],让你找出最长 ...

随机推荐

  1. blocked because of many connection errors; unblock with 'mysqladmin flush-hosts;MySQL在远程访问时非常慢的解决方法;MySql链接慢的解决方法

     一:服务器异常:Host 'xx.xxx.xx.xxx' is blocked because of many connection errors; unblock with 'mysqladmin ...

  2. 自己实现内存操作函数memset(),memcmp(),memcpy(),memmove()

    1.memset()内存设置函数(初始化) void *my_memset(void* dest, int c, size_t count) { assert(dest != NULL); char  ...

  3. 使用Phalcon开发工具碰到的数据库问题"Table 'XXX' doesn't exist in database when dumping meta-data for XXX"

    使用Phalcon开发工具,通过命令行生成程序框架 设置好config.php,在对数据库进行读取.保存数据的时候出现了问题“Table 'XXX' doesn't exist in database ...

  4. Java 碰撞的球 MovingBall (整理)

    package demo; /** * Java 碰撞的球 MovingBall (整理) * 声明: * 这份源代码没有注释,已经忘记了为什么要写他了,基本上应该是因为当时觉得好玩吧. * 有时候想 ...

  5. 详解Android动画之Frame Animation(转)

    在开始实例讲解之前,先引用官方文档中的一段话: Frame动画是一系列图片按照一定的顺序展示的过程,和放电影的机制很相似,我们称为逐帧动画.Frame动画可以被定义在XML文件中,也可以完全编码实现. ...

  6. Spark RDD操作(1)

    https://www.zybuluo.com/jewes/note/35032 RDD是什么? RDD是Spark中的抽象数据结构类型,任何数据在Spark中都被表示为RDD.从编程的角度来看,RD ...

  7. 【django】django深入学习笔记

    官网教程 DjangoBook Models 模型 一个类代表一个模型 类中的属性对应了对应数据表的数据 *makemirgations命令生成数据库脚本(还未同步过数据库,第一次要用到) - > ...

  8. mysql 在大型应用中的架构演变

    文正整理自:http://www.csdn.net/article/2014-06-10/2820160 可扩展性 架构的可扩展性往往和并发是息息相关,没有并发的增长,也就没有必要做高可扩展性的架构, ...

  9. Undefined symbols for architecture armv7

    xcode编译过程中出现如下问题Undefined symbols for architecture armv7:... ld: symbol(s) not found for architectur ...

  10. 嵌入式 Linux进程含义知多少

    理想情况下,您应该明白在您的系统中运行的每一个进程.要获得所有进程的列表,可以执行命令 ps -ef(POSIX 风格)或 ps ax(BSD 风格).进程名有方括号的是内核级的进程,执行辅助功能(比 ...