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

Envío 3878

Problema 0x94 - Subarreglo de máxima suma

  • Autor: Jhon_z09
  • Fecha: 2021-04-20 19:26:34 UTC (Hace más de 3 años)
Caso # Resultado Tiempo Memoria
#1
Error de compilación
                      main.cpp:9:16: warning: implicit conversion of out of range value from 'double' to 'int' is undefined [-Wliteral-conversion]
    int best = -10e9; sum = -10e9;
        ~~~~   ^~~~~
main.cpp:9:23: error: use of undeclared identifier 'sum'
    int best = -10e9; sum = -10e9;
                      ^
main.cpp:11:8: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
       ^
main.cpp:11:18: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
                 ^
main.cpp:11:23: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
                      ^
main.cpp:12:19: error: use of undeclared identifier 'sum'
       best = max(sum, best);
                  ^
1 warning and 5 errors generated.

                    
#2
Error de compilación
                      main.cpp:9:16: warning: implicit conversion of out of range value from 'double' to 'int' is undefined [-Wliteral-conversion]
    int best = -10e9; sum = -10e9;
        ~~~~   ^~~~~
main.cpp:9:23: error: use of undeclared identifier 'sum'
    int best = -10e9; sum = -10e9;
                      ^
main.cpp:11:8: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
       ^
main.cpp:11:18: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
                 ^
main.cpp:11:23: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
                      ^
main.cpp:12:19: error: use of undeclared identifier 'sum'
       best = max(sum, best);
                  ^
1 warning and 5 errors generated.

                    
#3
Error de compilación
                      main.cpp:9:16: warning: implicit conversion of out of range value from 'double' to 'int' is undefined [-Wliteral-conversion]
    int best = -10e9; sum = -10e9;
        ~~~~   ^~~~~
main.cpp:9:23: error: use of undeclared identifier 'sum'
    int best = -10e9; sum = -10e9;
                      ^
main.cpp:11:8: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
       ^
main.cpp:11:18: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
                 ^
main.cpp:11:23: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
                      ^
main.cpp:12:19: error: use of undeclared identifier 'sum'
       best = max(sum, best);
                  ^
1 warning and 5 errors generated.

                    
#4
Error de compilación
                      main.cpp:9:16: warning: implicit conversion of out of range value from 'double' to 'int' is undefined [-Wliteral-conversion]
    int best = -10e9; sum = -10e9;
        ~~~~   ^~~~~
main.cpp:9:23: error: use of undeclared identifier 'sum'
    int best = -10e9; sum = -10e9;
                      ^
main.cpp:11:8: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
       ^
main.cpp:11:18: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
                 ^
main.cpp:11:23: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
                      ^
main.cpp:12:19: error: use of undeclared identifier 'sum'
       best = max(sum, best);
                  ^
1 warning and 5 errors generated.

                    
#5
Error de compilación
                      main.cpp:9:16: warning: implicit conversion of out of range value from 'double' to 'int' is undefined [-Wliteral-conversion]
    int best = -10e9; sum = -10e9;
        ~~~~   ^~~~~
main.cpp:9:23: error: use of undeclared identifier 'sum'
    int best = -10e9; sum = -10e9;
                      ^
main.cpp:11:8: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
       ^
main.cpp:11:18: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
                 ^
main.cpp:11:23: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
                      ^
main.cpp:12:19: error: use of undeclared identifier 'sum'
       best = max(sum, best);
                  ^
1 warning and 5 errors generated.

                    
#6
Error de compilación
                      main.cpp:9:16: warning: implicit conversion of out of range value from 'double' to 'int' is undefined [-Wliteral-conversion]
    int best = -10e9; sum = -10e9;
        ~~~~   ^~~~~
main.cpp:9:23: error: use of undeclared identifier 'sum'
    int best = -10e9; sum = -10e9;
                      ^
main.cpp:11:8: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
       ^
main.cpp:11:18: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
                 ^
main.cpp:11:23: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
                      ^
main.cpp:12:19: error: use of undeclared identifier 'sum'
       best = max(sum, best);
                  ^
1 warning and 5 errors generated.

                    
#7
Error de compilación
                      main.cpp:9:16: warning: implicit conversion of out of range value from 'double' to 'int' is undefined [-Wliteral-conversion]
    int best = -10e9; sum = -10e9;
        ~~~~   ^~~~~
main.cpp:9:23: error: use of undeclared identifier 'sum'
    int best = -10e9; sum = -10e9;
                      ^
main.cpp:11:8: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
       ^
main.cpp:11:18: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
                 ^
main.cpp:11:23: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
                      ^
main.cpp:12:19: error: use of undeclared identifier 'sum'
       best = max(sum, best);
                  ^
1 warning and 5 errors generated.

                    
#8
Error de compilación
                      main.cpp:9:16: warning: implicit conversion of out of range value from 'double' to 'int' is undefined [-Wliteral-conversion]
    int best = -10e9; sum = -10e9;
        ~~~~   ^~~~~
main.cpp:9:23: error: use of undeclared identifier 'sum'
    int best = -10e9; sum = -10e9;
                      ^
main.cpp:11:8: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
       ^
main.cpp:11:18: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
                 ^
main.cpp:11:23: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
                      ^
main.cpp:12:19: error: use of undeclared identifier 'sum'
       best = max(sum, best);
                  ^
1 warning and 5 errors generated.

                    
#9
Error de compilación
                      main.cpp:9:16: warning: implicit conversion of out of range value from 'double' to 'int' is undefined [-Wliteral-conversion]
    int best = -10e9; sum = -10e9;
        ~~~~   ^~~~~
main.cpp:9:23: error: use of undeclared identifier 'sum'
    int best = -10e9; sum = -10e9;
                      ^
main.cpp:11:8: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
       ^
main.cpp:11:18: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
                 ^
main.cpp:11:23: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
                      ^
main.cpp:12:19: error: use of undeclared identifier 'sum'
       best = max(sum, best);
                  ^
1 warning and 5 errors generated.

                    
#10
Error de compilación
                      main.cpp:9:16: warning: implicit conversion of out of range value from 'double' to 'int' is undefined [-Wliteral-conversion]
    int best = -10e9; sum = -10e9;
        ~~~~   ^~~~~
main.cpp:9:23: error: use of undeclared identifier 'sum'
    int best = -10e9; sum = -10e9;
                      ^
main.cpp:11:8: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
       ^
main.cpp:11:18: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
                 ^
main.cpp:11:23: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
                      ^
main.cpp:12:19: error: use of undeclared identifier 'sum'
       best = max(sum, best);
                  ^
1 warning and 5 errors generated.

                    
#11
Error de compilación
                      main.cpp:9:16: warning: implicit conversion of out of range value from 'double' to 'int' is undefined [-Wliteral-conversion]
    int best = -10e9; sum = -10e9;
        ~~~~   ^~~~~
main.cpp:9:23: error: use of undeclared identifier 'sum'
    int best = -10e9; sum = -10e9;
                      ^
main.cpp:11:8: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
       ^
main.cpp:11:18: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
                 ^
main.cpp:11:23: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
                      ^
main.cpp:12:19: error: use of undeclared identifier 'sum'
       best = max(sum, best);
                  ^
1 warning and 5 errors generated.

                    
#12
Error de compilación
                      main.cpp:9:16: warning: implicit conversion of out of range value from 'double' to 'int' is undefined [-Wliteral-conversion]
    int best = -10e9; sum = -10e9;
        ~~~~   ^~~~~
main.cpp:9:23: error: use of undeclared identifier 'sum'
    int best = -10e9; sum = -10e9;
                      ^
main.cpp:11:8: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
       ^
main.cpp:11:18: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
                 ^
main.cpp:11:23: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
                      ^
main.cpp:12:19: error: use of undeclared identifier 'sum'
       best = max(sum, best);
                  ^
1 warning and 5 errors generated.

                    
#13
Error de compilación
                      main.cpp:9:16: warning: implicit conversion of out of range value from 'double' to 'int' is undefined [-Wliteral-conversion]
    int best = -10e9; sum = -10e9;
        ~~~~   ^~~~~
main.cpp:9:23: error: use of undeclared identifier 'sum'
    int best = -10e9; sum = -10e9;
                      ^
main.cpp:11:8: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
       ^
main.cpp:11:18: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
                 ^
main.cpp:11:23: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
                      ^
main.cpp:12:19: error: use of undeclared identifier 'sum'
       best = max(sum, best);
                  ^
1 warning and 5 errors generated.

                    
#14
Error de compilación
                      main.cpp:9:16: warning: implicit conversion of out of range value from 'double' to 'int' is undefined [-Wliteral-conversion]
    int best = -10e9; sum = -10e9;
        ~~~~   ^~~~~
main.cpp:9:23: error: use of undeclared identifier 'sum'
    int best = -10e9; sum = -10e9;
                      ^
main.cpp:11:8: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
       ^
main.cpp:11:18: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
                 ^
main.cpp:11:23: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
                      ^
main.cpp:12:19: error: use of undeclared identifier 'sum'
       best = max(sum, best);
                  ^
1 warning and 5 errors generated.

                    
#15
Error de compilación
                      main.cpp:9:16: warning: implicit conversion of out of range value from 'double' to 'int' is undefined [-Wliteral-conversion]
    int best = -10e9; sum = -10e9;
        ~~~~   ^~~~~
main.cpp:9:23: error: use of undeclared identifier 'sum'
    int best = -10e9; sum = -10e9;
                      ^
main.cpp:11:8: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
       ^
main.cpp:11:18: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
                 ^
main.cpp:11:23: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
                      ^
main.cpp:12:19: error: use of undeclared identifier 'sum'
       best = max(sum, best);
                  ^
1 warning and 5 errors generated.

                    
#16
Error de compilación
                      main.cpp:9:16: warning: implicit conversion of out of range value from 'double' to 'int' is undefined [-Wliteral-conversion]
    int best = -10e9; sum = -10e9;
        ~~~~   ^~~~~
main.cpp:9:23: error: use of undeclared identifier 'sum'
    int best = -10e9; sum = -10e9;
                      ^
main.cpp:11:8: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
       ^
main.cpp:11:18: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
                 ^
main.cpp:11:23: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
                      ^
main.cpp:12:19: error: use of undeclared identifier 'sum'
       best = max(sum, best);
                  ^
1 warning and 5 errors generated.

                    
#17
Error de compilación
                      main.cpp:9:16: warning: implicit conversion of out of range value from 'double' to 'int' is undefined [-Wliteral-conversion]
    int best = -10e9; sum = -10e9;
        ~~~~   ^~~~~
main.cpp:9:23: error: use of undeclared identifier 'sum'
    int best = -10e9; sum = -10e9;
                      ^
main.cpp:11:8: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
       ^
main.cpp:11:18: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
                 ^
main.cpp:11:23: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
                      ^
main.cpp:12:19: error: use of undeclared identifier 'sum'
       best = max(sum, best);
                  ^
1 warning and 5 errors generated.

                    
#18
Error de compilación
                      main.cpp:9:16: warning: implicit conversion of out of range value from 'double' to 'int' is undefined [-Wliteral-conversion]
    int best = -10e9; sum = -10e9;
        ~~~~   ^~~~~
main.cpp:9:23: error: use of undeclared identifier 'sum'
    int best = -10e9; sum = -10e9;
                      ^
main.cpp:11:8: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
       ^
main.cpp:11:18: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
                 ^
main.cpp:11:23: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
                      ^
main.cpp:12:19: error: use of undeclared identifier 'sum'
       best = max(sum, best);
                  ^
1 warning and 5 errors generated.

                    
#19
Error de compilación
                      main.cpp:9:16: warning: implicit conversion of out of range value from 'double' to 'int' is undefined [-Wliteral-conversion]
    int best = -10e9; sum = -10e9;
        ~~~~   ^~~~~
main.cpp:9:23: error: use of undeclared identifier 'sum'
    int best = -10e9; sum = -10e9;
                      ^
main.cpp:11:8: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
       ^
main.cpp:11:18: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
                 ^
main.cpp:11:23: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
                      ^
main.cpp:12:19: error: use of undeclared identifier 'sum'
       best = max(sum, best);
                  ^
1 warning and 5 errors generated.

                    
#20
Error de compilación
                      main.cpp:9:16: warning: implicit conversion of out of range value from 'double' to 'int' is undefined [-Wliteral-conversion]
    int best = -10e9; sum = -10e9;
        ~~~~   ^~~~~
main.cpp:9:23: error: use of undeclared identifier 'sum'
    int best = -10e9; sum = -10e9;
                      ^
main.cpp:11:8: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
       ^
main.cpp:11:18: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
                 ^
main.cpp:11:23: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
                      ^
main.cpp:12:19: error: use of undeclared identifier 'sum'
       best = max(sum, best);
                  ^
1 warning and 5 errors generated.

                    
#21
Error de compilación
                      main.cpp:9:16: warning: implicit conversion of out of range value from 'double' to 'int' is undefined [-Wliteral-conversion]
    int best = -10e9; sum = -10e9;
        ~~~~   ^~~~~
main.cpp:9:23: error: use of undeclared identifier 'sum'
    int best = -10e9; sum = -10e9;
                      ^
main.cpp:11:8: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
       ^
main.cpp:11:18: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
                 ^
main.cpp:11:23: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
                      ^
main.cpp:12:19: error: use of undeclared identifier 'sum'
       best = max(sum, best);
                  ^
1 warning and 5 errors generated.

                    
#22
Error de compilación
                      main.cpp:9:16: warning: implicit conversion of out of range value from 'double' to 'int' is undefined [-Wliteral-conversion]
    int best = -10e9; sum = -10e9;
        ~~~~   ^~~~~
main.cpp:9:23: error: use of undeclared identifier 'sum'
    int best = -10e9; sum = -10e9;
                      ^
main.cpp:11:8: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
       ^
main.cpp:11:18: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
                 ^
main.cpp:11:23: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
                      ^
main.cpp:12:19: error: use of undeclared identifier 'sum'
       best = max(sum, best);
                  ^
1 warning and 5 errors generated.

                    
#23
Error de compilación
                      main.cpp:9:16: warning: implicit conversion of out of range value from 'double' to 'int' is undefined [-Wliteral-conversion]
    int best = -10e9; sum = -10e9;
        ~~~~   ^~~~~
main.cpp:9:23: error: use of undeclared identifier 'sum'
    int best = -10e9; sum = -10e9;
                      ^
main.cpp:11:8: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
       ^
main.cpp:11:18: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
                 ^
main.cpp:11:23: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
                      ^
main.cpp:12:19: error: use of undeclared identifier 'sum'
       best = max(sum, best);
                  ^
1 warning and 5 errors generated.

                    
#24
Error de compilación
                      main.cpp:9:16: warning: implicit conversion of out of range value from 'double' to 'int' is undefined [-Wliteral-conversion]
    int best = -10e9; sum = -10e9;
        ~~~~   ^~~~~
main.cpp:9:23: error: use of undeclared identifier 'sum'
    int best = -10e9; sum = -10e9;
                      ^
main.cpp:11:8: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
       ^
main.cpp:11:18: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
                 ^
main.cpp:11:23: error: use of undeclared identifier 'sum'
       sum = max(sum, sum + i);
                      ^
main.cpp:12:19: error: use of undeclared identifier 'sum'
       best = max(sum, best);
                  ^
1 warning and 5 errors generated.

                    
Puntos totales: 0 / 100

Código

#include <bits/stdc++.h>
using namespace std;

int main(){
    int n; cin >> n;
    vector<int> arr(n);
    for(int i = 0;i < n; ++i) cin >> arr[i];
    
    int best = -10e9; sum = -10e9;
    for(int i: arr){
       sum = max(sum, sum + i);
       best = max(sum, best);
   }
   cout << best;
   
   return 0;
}