zoukankan      html  css  js  c++  java
  • Codeforces Round #321 (Div. 2) Kefa and First Steps 模拟

    原题连接:http://codeforces.com/contest/580/problem/A

    题意:

    给你一个序列,问你最长不降子串是多长?

    题解:

    直接模拟就好了

    代码:

    #include<iostream>
    using namespace std;
    
    int n;
    
    int main() {
        cin.sync_with_stdio(false);
        cin >> n;
        int p;
        cin >> p;
        if (n == 1) {
            cout << 1 << endl;
            return 0;
        }
        int maxLen = 1;
        int now = 1;
        for (int i = 1; i < n; i++) {
            int a;
            cin >> a;
            if (a >= p) {
                now++;
                maxLen = max(maxLen, now);
            }
            else {
                maxLen = max(maxLen, now);
                now = 1;
            }
            p = a;
        }
        cout << max(now, maxLen) << endl;
        return 0;
    }
  • 相关阅读:
    Java设计模式——单例模式
    Java设计模式——工厂模式
    多线程
    Collection集合
    内部类
    多态
    接口
    面向对象(2)
    数组
    面向对象(1)
  • 原文地址:https://www.cnblogs.com/HarryGuo2012/p/4831098.html
Copyright © 2011-2022 走看看