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

Envío 2189

Problema 0x94 - Subarreglo de máxima suma

  • Autor: judavid.arias
  • Fecha: 2020-11-28 21:02:32 UTC (Hace alrededor de 2 años)
Caso # Resultado Tiempo Memoria
#1
Error de compilación
                      main.cpp:11:13: error: use of undeclared identifier 'INT_MIN'
        int resp = INT_MIN;
                   ^
1 error generated.

                    
#2
Error de compilación
                      main.cpp:11:13: error: use of undeclared identifier 'INT_MIN'
        int resp = INT_MIN;
                   ^
1 error generated.

                    
#3
Error de compilación
                      main.cpp:11:13: error: use of undeclared identifier 'INT_MIN'
        int resp = INT_MIN;
                   ^
1 error generated.

                    
#4
Error de compilación
                      main.cpp:11:13: error: use of undeclared identifier 'INT_MIN'
        int resp = INT_MIN;
                   ^
1 error generated.

                    
#5
Error de compilación
                      main.cpp:11:13: error: use of undeclared identifier 'INT_MIN'
        int resp = INT_MIN;
                   ^
1 error generated.

                    
#6
Error de compilación
                      main.cpp:11:13: error: use of undeclared identifier 'INT_MIN'
        int resp = INT_MIN;
                   ^
1 error generated.

                    
#7
Error de compilación
                      main.cpp:11:13: error: use of undeclared identifier 'INT_MIN'
        int resp = INT_MIN;
                   ^
1 error generated.

                    
#8
Error de compilación
                      main.cpp:11:13: error: use of undeclared identifier 'INT_MIN'
        int resp = INT_MIN;
                   ^
1 error generated.

                    
#9
Error de compilación
                      main.cpp:11:13: error: use of undeclared identifier 'INT_MIN'
        int resp = INT_MIN;
                   ^
1 error generated.

                    
#10
Error de compilación
                      main.cpp:11:13: error: use of undeclared identifier 'INT_MIN'
        int resp = INT_MIN;
                   ^
1 error generated.

                    
#11
Error de compilación
                      main.cpp:11:13: error: use of undeclared identifier 'INT_MIN'
        int resp = INT_MIN;
                   ^
1 error generated.

                    
#12
Error de compilación
                      main.cpp:11:13: error: use of undeclared identifier 'INT_MIN'
        int resp = INT_MIN;
                   ^
1 error generated.

                    
#13
Error de compilación
                      main.cpp:11:13: error: use of undeclared identifier 'INT_MIN'
        int resp = INT_MIN;
                   ^
1 error generated.

                    
#14
Error de compilación
                      main.cpp:11:13: error: use of undeclared identifier 'INT_MIN'
        int resp = INT_MIN;
                   ^
1 error generated.

                    
#15
Error de compilación
                      main.cpp:11:13: error: use of undeclared identifier 'INT_MIN'
        int resp = INT_MIN;
                   ^
1 error generated.

                    
#16
Error de compilación
                      main.cpp:11:13: error: use of undeclared identifier 'INT_MIN'
        int resp = INT_MIN;
                   ^
1 error generated.

                    
#17
Error de compilación
                      main.cpp:11:13: error: use of undeclared identifier 'INT_MIN'
        int resp = INT_MIN;
                   ^
1 error generated.

                    
#18
Error de compilación
                      main.cpp:11:13: error: use of undeclared identifier 'INT_MIN'
        int resp = INT_MIN;
                   ^
1 error generated.

                    
#19
Error de compilación
                      main.cpp:11:13: error: use of undeclared identifier 'INT_MIN'
        int resp = INT_MIN;
                   ^
1 error generated.

                    
#20
Error de compilación
                      main.cpp:11:13: error: use of undeclared identifier 'INT_MIN'
        int resp = INT_MIN;
                   ^
1 error generated.

                    
#21
Error de compilación
                      main.cpp:11:13: error: use of undeclared identifier 'INT_MIN'
        int resp = INT_MIN;
                   ^
1 error generated.

                    
#22
Error de compilación
                      main.cpp:11:13: error: use of undeclared identifier 'INT_MIN'
        int resp = INT_MIN;
                   ^
1 error generated.

                    
#23
Error de compilación
                      main.cpp:11:13: error: use of undeclared identifier 'INT_MIN'
        int resp = INT_MIN;
                   ^
1 error generated.

                    
#24
Error de compilación
                      main.cpp:11:13: error: use of undeclared identifier 'INT_MIN'
        int resp = INT_MIN;
                   ^
1 error generated.

                    
Puntos totales: 0 / 100

Código

#include <iostream>
#include <algorithm>    // std::max
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main() {
	int N;
	cin >> N;
	int data[N];
	int sums[N];
	int resp = INT_MIN;
	for(int i =0;i<N;i++){
		cin >> data[i];
		if(i==0){
			sums[i] = data[i];
		}else{
			int tmp = data[i]+sums[i-1];
			sums[i] = max(tmp, data[i]);
		}
		resp = max(resp, sums[i]);
	}
	cout << resp;
	return 0;
}