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

Envío 3826

Problema 0xf2 - Partir un arreglo grande en 2

  • Autor: bryancalisto
  • Fecha: 2021-04-17 20:46:29 UTC (Hace casi 3 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.004 s 2 KBi
#2
Correcto
0.004 s 1 KBi
#3
Correcto
0.005 s 6 KBi
#4
Correcto
0.007 s 7 KBi
#5
Correcto
0.004 s 3 KBi
#6
Correcto
0.002 s 2 KBi
#7
Correcto
0.002 s 2 KBi
#8
Correcto
0.002 s 1 KBi
#9
Correcto
0.004 s 2 KBi
#10
Error en tiempo de ejecución (NZEC)
Exited with error status 134
a.out: malloc.c:2385: sysmalloc: Assertion `(old_top == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)' failed.
run: line 1:     3 Aborted                 (core dumped) ./a.out
0.002 s 1 KBi
#11
Error en tiempo de ejecución (NZEC)
Exited with error status 134
malloc(): corrupted top size
run: line 1:     3 Aborted                 (core dumped) ./a.out
0.002 s 2 KBi
#12
Error en tiempo de ejecución (NZEC)
Exited with error status 134
malloc(): corrupted top size
run: line 1:     3 Aborted                 (core dumped) ./a.out
0.005 s 2 KBi
#13
Error en tiempo de ejecución (NZEC)
Exited with error status 134
malloc(): corrupted top size
run: line 1:     3 Aborted                 (core dumped) ./a.out
0.005 s 2 KBi
#14
Error en tiempo de ejecución (NZEC)
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.016 s 2 KBi
#15
Error en tiempo de ejecución (NZEC)
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.016 s 2 KBi
#16
Error en tiempo de ejecución (NZEC)
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.019 s 2 KBi
#17
Error en tiempo de ejecución (NZEC)
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.019 s 2 KBi
#18
Error en tiempo de ejecución (NZEC)
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.02 s 2 KBi
#19
Error en tiempo de ejecución (NZEC)
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.015 s 2 KBi
#20
Error en tiempo de ejecución (NZEC)
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.026 s 1 KBi
Puntos totales: 45 / 100

Código

#include<stdio.h>
#include<stdlib.h>

int main()
{
  int N, *arr, i = 0, j = 0, sumIzq = 0, sumDer = 0, puntoDeCorte;

  fscanf(stdin, "%d", &N);
  arr = (int *)malloc(N + 1);

  while (j < N && fscanf(stdin, "%d", arr + j++) == 1)
    ;

  for (i = 0; i < N; i++)
  {
    sumDer += arr[i];
  }

  for (i = 0; i < N; i++)
  {
    sumDer -= arr[i];
    sumIzq += arr[i];

    if (sumDer < 0 && sumIzq > 0)
    {
      printf("%d\n", i + 1);
      free(arr);
      return 0;
    }
  }
  printf("Impossible\n");
  free(arr);
  return 0;
}