Cod sursa(job #3205150)

Utilizator JulyaBuhBuhai Iulia JulyaBuh Data 18 februarie 2024 22:16:41
Problema Subsir crescator maximal Scor 10
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.77 kb
#include <iostream>
#include <fstream>
using namespace std;

ifstream fin("scmax.in");
ofstream fout("scmax.out");

int main() {
    int n;
    fin >> n;
    int x, y;
    int lungime = 1; // Start with length 1 for the first element
    int lungimeMax = 1; // Initialize max length to 1
    fin >> x;
    while (fin >> y) {
        if (x < y) {
            lungime++; // Increase length if the sequence is increasing
        } else {
            lungime = 1; // Reset length if the sequence is not increasing
        }
        if (lungime > lungimeMax) {
            lungimeMax = lungime; // Update max length if necessary
        }
        x = y; // Update previous element
    }
    fout << lungimeMax;
    fin.close();
    fout.close();
    return 0;
}