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

Envío 1063

Problema 0xf2 - Partir un arreglo grande en 2

  • Autor: juantamayo26
  • Fecha: 2020-10-09 16:22:29 UTC (Hace más de 3 años)
Caso # Resultado Tiempo Memoria
#1
Error de compilación
                      Compilation time limit exceeded.
                    
#2
Error de compilación
                      Compilation time limit exceeded.
                    
#3
Error de compilación
                      Compilation time limit exceeded.
                    
#4
Error de compilación
                      Compilation time limit exceeded.
                    
#5
Error de compilación
                      Compilation time limit exceeded.
                    
#6
Error de compilación
                      Compilation time limit exceeded.
                    
#7
Error de compilación
                      Compilation time limit exceeded.
                    
#8
Error de compilación
                      Compilation time limit exceeded.
                    
#9
Error de compilación
                      Compilation time limit exceeded.
                    
#10
Error de compilación
                      Compilation time limit exceeded.
                    
#11
Error de compilación
                      Compilation time limit exceeded.
                    
#12
Error de compilación
                      Compilation time limit exceeded.
                    
#13
Incorrecto
0.006 s 5 KBi
#14
Incorrecto
0.049 s 10 KBi
#15
Error de compilación
                      Compilation time limit exceeded.
                    
#16
Correcto
0.046 s 10 KBi
#17
Incorrecto
0.046 s 14 KBi
#18
Incorrecto
0.044 s 10 KBi
#19
Incorrecto
0.047 s 10 KBi
#20
Incorrecto
0.065 s 13 KBi
Puntos totales: 5 / 100

Código

#include <bits/stdc++.h>

using namespace std;

#define endl '\n'
#define ll long long
const int maxi = 500011;
ll a[maxi];
ll prefix[maxi];

int main(){
  ios::sync_with_stdio(0); cin.tie(0); 
  int n;
  cin>>n;
  for(int i=0;i<n; i++){
    cin>>a[i];
  }
  for(int i=n-2; i>=0; i--){
    prefix[i]=prefix[i+1]+a[i];
  }
  int aux=0;
  for(int i=0; i<n; i++){
    if(prefix[i]>0){
      aux=i;
      break;
    }
  }
  if(prefix[aux]<0){
    cout<<"Impossible"<<endl;
    return 0;
  }
  for(int i=aux+1;i<n; i++){
    if(prefix[i]<0){
      cout<<i<<endl;
      return 0;
    }
  }
  cout<<"Impossible"<<endl;
  return 0;
}