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

Envío 2177

Problema 0x94 - Subarreglo de máxima suma

  • Autor: ppastram
  • Fecha: 2020-11-27 17:55:04 UTC (Hace alrededor de 4 años)
Caso # Resultado Tiempo Memoria
#1
Error de compilación
                      main.cpp:34:15: error: use of undeclared identifier 'INT_MAX'
    int min = INT_MAX;
              ^
main.cpp:35:15: error: use of undeclared identifier 'INT_MIN'
    int res = INT_MIN;
              ^
2 errors generated.

                    
#2
Error de compilación
                      main.cpp:34:15: error: use of undeclared identifier 'INT_MAX'
    int min = INT_MAX;
              ^
main.cpp:35:15: error: use of undeclared identifier 'INT_MIN'
    int res = INT_MIN;
              ^
2 errors generated.

                    
#3
Error de compilación
                      main.cpp:34:15: error: use of undeclared identifier 'INT_MAX'
    int min = INT_MAX;
              ^
main.cpp:35:15: error: use of undeclared identifier 'INT_MIN'
    int res = INT_MIN;
              ^
2 errors generated.

                    
#4
Error de compilación
                      main.cpp:34:15: error: use of undeclared identifier 'INT_MAX'
    int min = INT_MAX;
              ^
main.cpp:35:15: error: use of undeclared identifier 'INT_MIN'
    int res = INT_MIN;
              ^
2 errors generated.

                    
#5
Error de compilación
                      main.cpp:34:15: error: use of undeclared identifier 'INT_MAX'
    int min = INT_MAX;
              ^
main.cpp:35:15: error: use of undeclared identifier 'INT_MIN'
    int res = INT_MIN;
              ^
2 errors generated.

                    
#6
Error de compilación
                      main.cpp:34:15: error: use of undeclared identifier 'INT_MAX'
    int min = INT_MAX;
              ^
main.cpp:35:15: error: use of undeclared identifier 'INT_MIN'
    int res = INT_MIN;
              ^
2 errors generated.

                    
#7
Error de compilación
                      main.cpp:34:15: error: use of undeclared identifier 'INT_MAX'
    int min = INT_MAX;
              ^
main.cpp:35:15: error: use of undeclared identifier 'INT_MIN'
    int res = INT_MIN;
              ^
2 errors generated.

                    
#8
Error de compilación
                      main.cpp:34:15: error: use of undeclared identifier 'INT_MAX'
    int min = INT_MAX;
              ^
main.cpp:35:15: error: use of undeclared identifier 'INT_MIN'
    int res = INT_MIN;
              ^
2 errors generated.

                    
#9
Error de compilación
                      main.cpp:34:15: error: use of undeclared identifier 'INT_MAX'
    int min = INT_MAX;
              ^
main.cpp:35:15: error: use of undeclared identifier 'INT_MIN'
    int res = INT_MIN;
              ^
2 errors generated.

                    
#10
Error de compilación
                      main.cpp:34:15: error: use of undeclared identifier 'INT_MAX'
    int min = INT_MAX;
              ^
main.cpp:35:15: error: use of undeclared identifier 'INT_MIN'
    int res = INT_MIN;
              ^
2 errors generated.

                    
#11
Error de compilación
                      main.cpp:34:15: error: use of undeclared identifier 'INT_MAX'
    int min = INT_MAX;
              ^
main.cpp:35:15: error: use of undeclared identifier 'INT_MIN'
    int res = INT_MIN;
              ^
2 errors generated.

                    
#12
Error de compilación
                      main.cpp:34:15: error: use of undeclared identifier 'INT_MAX'
    int min = INT_MAX;
              ^
main.cpp:35:15: error: use of undeclared identifier 'INT_MIN'
    int res = INT_MIN;
              ^
2 errors generated.

                    
#13
Error de compilación
                      main.cpp:34:15: error: use of undeclared identifier 'INT_MAX'
    int min = INT_MAX;
              ^
main.cpp:35:15: error: use of undeclared identifier 'INT_MIN'
    int res = INT_MIN;
              ^
2 errors generated.

                    
#14
Error de compilación
                      main.cpp:34:15: error: use of undeclared identifier 'INT_MAX'
    int min = INT_MAX;
              ^
main.cpp:35:15: error: use of undeclared identifier 'INT_MIN'
    int res = INT_MIN;
              ^
2 errors generated.

                    
#15
Error de compilación
                      main.cpp:34:15: error: use of undeclared identifier 'INT_MAX'
    int min = INT_MAX;
              ^
main.cpp:35:15: error: use of undeclared identifier 'INT_MIN'
    int res = INT_MIN;
              ^
2 errors generated.

                    
#16
Error de compilación
                      main.cpp:34:15: error: use of undeclared identifier 'INT_MAX'
    int min = INT_MAX;
              ^
main.cpp:35:15: error: use of undeclared identifier 'INT_MIN'
    int res = INT_MIN;
              ^
2 errors generated.

                    
#17
Error de compilación
                      main.cpp:34:15: error: use of undeclared identifier 'INT_MAX'
    int min = INT_MAX;
              ^
main.cpp:35:15: error: use of undeclared identifier 'INT_MIN'
    int res = INT_MIN;
              ^
2 errors generated.

                    
#18
Error de compilación
                      main.cpp:34:15: error: use of undeclared identifier 'INT_MAX'
    int min = INT_MAX;
              ^
main.cpp:35:15: error: use of undeclared identifier 'INT_MIN'
    int res = INT_MIN;
              ^
2 errors generated.

                    
#19
Error de compilación
                      main.cpp:34:15: error: use of undeclared identifier 'INT_MAX'
    int min = INT_MAX;
              ^
main.cpp:35:15: error: use of undeclared identifier 'INT_MIN'
    int res = INT_MIN;
              ^
2 errors generated.

                    
#20
Error de compilación
                      main.cpp:34:15: error: use of undeclared identifier 'INT_MAX'
    int min = INT_MAX;
              ^
main.cpp:35:15: error: use of undeclared identifier 'INT_MIN'
    int res = INT_MIN;
              ^
2 errors generated.

                    
#21
Error de compilación
                      main.cpp:34:15: error: use of undeclared identifier 'INT_MAX'
    int min = INT_MAX;
              ^
main.cpp:35:15: error: use of undeclared identifier 'INT_MIN'
    int res = INT_MIN;
              ^
2 errors generated.

                    
#22
Error de compilación
                      main.cpp:34:15: error: use of undeclared identifier 'INT_MAX'
    int min = INT_MAX;
              ^
main.cpp:35:15: error: use of undeclared identifier 'INT_MIN'
    int res = INT_MIN;
              ^
2 errors generated.

                    
#23
Error de compilación
                      main.cpp:34:15: error: use of undeclared identifier 'INT_MAX'
    int min = INT_MAX;
              ^
main.cpp:35:15: error: use of undeclared identifier 'INT_MIN'
    int res = INT_MIN;
              ^
2 errors generated.

                    
#24
Error de compilación
                      main.cpp:34:15: error: use of undeclared identifier 'INT_MAX'
    int min = INT_MAX;
              ^
main.cpp:35:15: error: use of undeclared identifier 'INT_MIN'
    int res = INT_MIN;
              ^
2 errors generated.

                    
Puntos totales: 0 / 100

Código

#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <algorithm>
#define forn(a, n) for(int a = 0; a<(int) (n); ++a)
#define rforn(a, n) for(int a = (n)-1; a>=0; --a)
using namespace std;
const int N = 6e5+20;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n;
    cin>>n;
    vector<int> nums (n+1);
    vector<int> sums (n+1);

    for(int i = 0; i < n; i++)
    {
        cin>>nums[i];
        if(i==0) sums[0] = nums[0];
        else sums[i] = sums[i-1] + nums[i];
        //cout<<sums[i]<<endl;
    }

    int min = INT_MAX;
    int res = INT_MIN;

    for(int i = 0; i < n; i++)
    {
        if(sums[i]<min)
        { 
            min = sums[i];
            res = max(res, max(nums[i], sums[i]));
        }
        else res = max(res, max(nums[i], max(sums[i]-min, sums[i])));
    }
    cout<<res<<endl;
}