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

Envío 3823

Problema 0xf2 - Partir un arreglo grande en 2

  • Autor: bryancalisto
  • Fecha: 2021-04-17 20:38:32 UTC (Hace casi 3 años)
Caso # Resultado Tiempo Memoria
#1
Error de compilación
                      main.c:27:7: error: non-void function 'main' should return a value [-Wreturn-type]
      return;
      ^
1 error generated.

                    
#2
Error de compilación
                      main.c:27:7: error: non-void function 'main' should return a value [-Wreturn-type]
      return;
      ^
1 error generated.

                    
#3
Error de compilación
                      main.c:27:7: error: non-void function 'main' should return a value [-Wreturn-type]
      return;
      ^
1 error generated.

                    
#4
Error de compilación
                      main.c:27:7: error: non-void function 'main' should return a value [-Wreturn-type]
      return;
      ^
1 error generated.

                    
#5
Error de compilación
                      main.c:27:7: error: non-void function 'main' should return a value [-Wreturn-type]
      return;
      ^
1 error generated.

                    
#6
Error de compilación
                      main.c:27:7: error: non-void function 'main' should return a value [-Wreturn-type]
      return;
      ^
1 error generated.

                    
#7
Error de compilación
                      main.c:27:7: error: non-void function 'main' should return a value [-Wreturn-type]
      return;
      ^
1 error generated.

                    
#8
Error de compilación
                      main.c:27:7: error: non-void function 'main' should return a value [-Wreturn-type]
      return;
      ^
1 error generated.

                    
#9
Error de compilación
                      main.c:27:7: error: non-void function 'main' should return a value [-Wreturn-type]
      return;
      ^
1 error generated.

                    
#10
Error de compilación
                      main.c:27:7: error: non-void function 'main' should return a value [-Wreturn-type]
      return;
      ^
1 error generated.

                    
#11
Error de compilación
                      main.c:27:7: error: non-void function 'main' should return a value [-Wreturn-type]
      return;
      ^
1 error generated.

                    
#12
Error de compilación
                      main.c:27:7: error: non-void function 'main' should return a value [-Wreturn-type]
      return;
      ^
1 error generated.

                    
#13
Error de compilación
                      main.c:27:7: error: non-void function 'main' should return a value [-Wreturn-type]
      return;
      ^
1 error generated.

                    
#14
Error de compilación
                      main.c:27:7: error: non-void function 'main' should return a value [-Wreturn-type]
      return;
      ^
1 error generated.

                    
#15
Error de compilación
                      main.c:27:7: error: non-void function 'main' should return a value [-Wreturn-type]
      return;
      ^
1 error generated.

                    
#16
Error de compilación
                      main.c:27:7: error: non-void function 'main' should return a value [-Wreturn-type]
      return;
      ^
1 error generated.

                    
#17
Error de compilación
                      main.c:27:7: error: non-void function 'main' should return a value [-Wreturn-type]
      return;
      ^
1 error generated.

                    
#18
Error de compilación
                      main.c:27:7: error: non-void function 'main' should return a value [-Wreturn-type]
      return;
      ^
1 error generated.

                    
#19
Error de compilación
                      main.c:27:7: error: non-void function 'main' should return a value [-Wreturn-type]
      return;
      ^
1 error generated.

                    
#20
Error de compilación
                      main.c:27:7: error: non-void function 'main' should return a value [-Wreturn-type]
      return;
      ^
1 error generated.

                    
Puntos totales: 0 / 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);

  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);
      return;
    }
  }
  printf("Impossible\n");
  free(arr);
}