█████████ ████ ███░░░░░███ ░░███ ███ ░░░ ██████ ███████ ██████ ██████ ░███ ███░░███ ███░░███ ███░░███ ███░░███ ░███ ░███ ░███░███ ░███ ░███████ ░███ ░███ ░░███ ███░███ ░███░███ ░███ ░███░░░ ░███ ░███ ░░█████████ ░░██████ ░░████████░░██████ ░░██████ ░░░░░░░░░ ░░░░░░ ░░░░░░░░ ░░░░░░ ░░░░░░

Envío 2222

Problema 0x94 - Subarreglo de máxima suma

  • Autor: tristanjs
  • Fecha: 2020-12-06 03:29:10 UTC (Hace alrededor de 4 años)
Caso # Resultado Tiempo Memoria
#1
Error de compilación
                      main.cpp:8:29: error: use of undeclared identifier 'INT_MIN'
    int cases, x, num_max = INT_MIN;
                            ^
1 error generated.

                    
#2
Error de compilación
                      main.cpp:8:29: error: use of undeclared identifier 'INT_MIN'
    int cases, x, num_max = INT_MIN;
                            ^
1 error generated.

                    
#3
Error de compilación
                      main.cpp:8:29: error: use of undeclared identifier 'INT_MIN'
    int cases, x, num_max = INT_MIN;
                            ^
1 error generated.

                    
#4
Error de compilación
                      main.cpp:8:29: error: use of undeclared identifier 'INT_MIN'
    int cases, x, num_max = INT_MIN;
                            ^
1 error generated.

                    
#5
Error de compilación
                      main.cpp:8:29: error: use of undeclared identifier 'INT_MIN'
    int cases, x, num_max = INT_MIN;
                            ^
1 error generated.

                    
#6
Error de compilación
                      main.cpp:8:29: error: use of undeclared identifier 'INT_MIN'
    int cases, x, num_max = INT_MIN;
                            ^
1 error generated.

                    
#7
Error de compilación
                      main.cpp:8:29: error: use of undeclared identifier 'INT_MIN'
    int cases, x, num_max = INT_MIN;
                            ^
1 error generated.

                    
#8
Error de compilación
                      main.cpp:8:29: error: use of undeclared identifier 'INT_MIN'
    int cases, x, num_max = INT_MIN;
                            ^
1 error generated.

                    
#9
Error de compilación
                      main.cpp:8:29: error: use of undeclared identifier 'INT_MIN'
    int cases, x, num_max = INT_MIN;
                            ^
1 error generated.

                    
#10
Error de compilación
                      main.cpp:8:29: error: use of undeclared identifier 'INT_MIN'
    int cases, x, num_max = INT_MIN;
                            ^
1 error generated.

                    
#11
Error de compilación
                      main.cpp:8:29: error: use of undeclared identifier 'INT_MIN'
    int cases, x, num_max = INT_MIN;
                            ^
1 error generated.

                    
#12
Error de compilación
                      main.cpp:8:29: error: use of undeclared identifier 'INT_MIN'
    int cases, x, num_max = INT_MIN;
                            ^
1 error generated.

                    
#13
Error de compilación
                      main.cpp:8:29: error: use of undeclared identifier 'INT_MIN'
    int cases, x, num_max = INT_MIN;
                            ^
1 error generated.

                    
#14
Error de compilación
                      main.cpp:8:29: error: use of undeclared identifier 'INT_MIN'
    int cases, x, num_max = INT_MIN;
                            ^
1 error generated.

                    
#15
Error de compilación
                      main.cpp:8:29: error: use of undeclared identifier 'INT_MIN'
    int cases, x, num_max = INT_MIN;
                            ^
1 error generated.

                    
#16
Error de compilación
                      main.cpp:8:29: error: use of undeclared identifier 'INT_MIN'
    int cases, x, num_max = INT_MIN;
                            ^
1 error generated.

                    
#17
Error de compilación
                      main.cpp:8:29: error: use of undeclared identifier 'INT_MIN'
    int cases, x, num_max = INT_MIN;
                            ^
1 error generated.

                    
#18
Error de compilación
                      main.cpp:8:29: error: use of undeclared identifier 'INT_MIN'
    int cases, x, num_max = INT_MIN;
                            ^
1 error generated.

                    
#19
Error de compilación
                      main.cpp:8:29: error: use of undeclared identifier 'INT_MIN'
    int cases, x, num_max = INT_MIN;
                            ^
1 error generated.

                    
#20
Error de compilación
                      main.cpp:8:29: error: use of undeclared identifier 'INT_MIN'
    int cases, x, num_max = INT_MIN;
                            ^
1 error generated.

                    
#21
Error de compilación
                      main.cpp:8:29: error: use of undeclared identifier 'INT_MIN'
    int cases, x, num_max = INT_MIN;
                            ^
1 error generated.

                    
#22
Error de compilación
                      main.cpp:8:29: error: use of undeclared identifier 'INT_MIN'
    int cases, x, num_max = INT_MIN;
                            ^
1 error generated.

                    
#23
Error de compilación
                      main.cpp:8:29: error: use of undeclared identifier 'INT_MIN'
    int cases, x, num_max = INT_MIN;
                            ^
1 error generated.

                    
#24
Error de compilación
                      main.cpp:8:29: error: use of undeclared identifier 'INT_MIN'
    int cases, x, num_max = INT_MIN;
                            ^
1 error generated.

                    
Puntos totales: 0 / 100

Código

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    int cases, x, num_max = INT_MIN;
    cin >> cases;
    vector <int> numbers;
    while ( cases-- ){
        cin >> x;
        numbers.push_back(x);
        num_max = max(num_max, x);
    }

    if(num_max <= 0){
        cout << num_max << endl;
        return 0;
    }

    int sum = numbers[0], sum_max = 0;
    for(int i=1;i<numbers.size(); i++){
        sum = max(sum + numbers[i], numbers[i]);
        num_max = max(num_max, sum);
    }

    cout << num_max << endl;
    return 0;
}