580A
来源:互联网 发布:手机sdr软件 编辑:程序博客网 时间:2024/06/16 17:13
题目大意:
给一段数组序列,求最长的非降序列;
题目分析:
我的思路是在开一个数组s,保存当前非降序列的个数,如果s[i] >= s[i-1]; s[i] = s[i-1]+1; 反之 s[i] = 1;
不过这个数组是可以不用的;
题目地址:点击打开链接
参考代码:
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;int n, a[100000+10];int main(){ while(scanf("%d", &n) != EOF){ for(int i = 0; i < n; ++i) scanf("%d", &a[i]); int _max = -1; int k = 1; for(int i = 1; i < n; ++i){ if(a[i] >= a[i-1]) k++; else k = 1; if(k > _max) _max = k; } _max = max(_max, k); printf("%d\n", _max); }}
0 0
- 580A
- cf 580 A
- Codeforces 580A
- a
- a
- a
- a
- a
- a
- a
- a
- a
- a
- a
- a
- a
- A
- A*
- C++静态库与动态库
- 找出平面上距离最近的两个点
- JNI浅析
- 没有数据分析大数据就什么也不是
- 5477 A Sweet Journey (贪心_上海网络赛)
- 580A
- HDU 5482(思路题目)
- 数据库相同版本的数据文件导入时出错
- 韩顺平 java 第21讲、第22讲、第23讲、第24讲 集合
- HDU 5475:An easy problem 这题也能用线段树做???
- VBS 调用 HTA 实现进度条加载
- Seoul 2007 Meteor 流星 ,LA 3905
- Android 开发中的日常积累
- stl string常用函数