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

Envío 5513

Problema 0x94 - Subarreglo de máxima suma

  • Autor: nivalderramas
  • Fecha: 2021-12-28 22:20:10 UTC (Hace más de 2 años)
Caso # Resultado Tiempo Memoria
#1
Error de compilación
                      Compilation time limit exceeded.
                    
#2
Correcto
0.004 s 4 KBi
#3
Error de compilación
                      Compilation time limit exceeded.
                    
#4
Correcto
0.003 s 0 KBi
#5
Correcto
0.006 s 0 KBi
#6
Error de compilación
                      Compilation time limit exceeded.
                    
#7
Error de compilación
                      Compilation time limit exceeded.
                    
#8
Correcto
0.003 s 0 KBi
#9
Correcto
0.006 s 2 KBi
#10
Correcto
0.004 s 12 KBi
#11
Correcto
0.005 s 0 KBi
#12
Error de compilación
                      Compilation time limit exceeded.
                    
#13
Correcto
0.006 s 6 KBi
#14
Correcto
0.007 s 0 KBi
#15
Correcto
0.002 s 0 KBi
#16
Error de compilación
                      Compilation time limit exceeded.
                    
#17
Incorrecto
0.005 s 1 KBi
#18
Correcto
0.02 s 1 KBi
#19
Correcto
0.008 s 1 KBi
#20
Error de compilación
                      Compilation time limit exceeded.
                    
#21
Incorrecto
0.004 s 1 KBi
#22
Incorrecto
0.019 s 5 KBi
#23
Correcto
0.01 s 1 KBi
#24
Error de compilación
                      Compilation time limit exceeded.
                    
Puntos totales: 55 / 100

Código

#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<n;i++)
#define pb push_back
#define ff first
#define ss second
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define lli long long int
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
ostream& operator<<(ostream& os, const vector<int> &v){
    for(auto const &i: v){
        os<<i<<" ";
    }
    os<<endl;
    return os;
}
const lli mod=(1e9)+7;
const int N = 1e4+1;
int main(){
    fast_io;
    int n;cin>>n;
    int nums[n];
    REP(i,n)cin>>nums[i];
    int mx = 0;
    int ans = -1e9;
    REP(i,n){
        mx += nums[i];
        ans = max(mx,ans);
        if(mx<0) mx = 0;
    }
    cout<<ans<<endl;
    return 0;
}