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

Envío 1236

Problema 0xf2 - Partir un arreglo grande en 2

  • Autor: EduardoVega
  • Fecha: 2020-10-12 08:05:54 UTC (Hace más de 3 años)
Caso # Resultado Tiempo Memoria
#1
Incorrecto
                      main.c:30:22: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
      printf("%d\n", i);
              ~~     ^
              %ld
1 warning generated.

                    
0.003 s 1 KBi
#2
Correcto
                      main.c:30:22: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
      printf("%d\n", i);
              ~~     ^
              %ld
1 warning generated.

                    
0.003 s 1 KBi
#3
Incorrecto
                      main.c:30:22: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
      printf("%d\n", i);
              ~~     ^
              %ld
1 warning generated.

                    
0.002 s 1 KBi
#4
Correcto
                      main.c:30:22: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
      printf("%d\n", i);
              ~~     ^
              %ld
1 warning generated.

                    
0.003 s 1 KBi
#5
Correcto
                      main.c:30:22: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
      printf("%d\n", i);
              ~~     ^
              %ld
1 warning generated.

                    
0.003 s 1 KBi
#6
Correcto
                      main.c:30:22: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
      printf("%d\n", i);
              ~~     ^
              %ld
1 warning generated.

                    
0.003 s 1 KBi
#7
Correcto
                      main.c:30:22: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
      printf("%d\n", i);
              ~~     ^
              %ld
1 warning generated.

                    
0.004 s 1 KBi
#8
Correcto
                      main.c:30:22: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
      printf("%d\n", i);
              ~~     ^
              %ld
1 warning generated.

                    
0.002 s 1 KBi
#9
Correcto
                      main.c:30:22: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
      printf("%d\n", i);
              ~~     ^
              %ld
1 warning generated.

                    
0.004 s 1 KBi
#10
Incorrecto
                      main.c:30:22: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
      printf("%d\n", i);
              ~~     ^
              %ld
1 warning generated.

                    
0.004 s 2 KBi
#11
Incorrecto
                      main.c:30:22: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
      printf("%d\n", i);
              ~~     ^
              %ld
1 warning generated.

                    
0.004 s 35 KBi
#12
Correcto
                      main.c:30:22: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
      printf("%d\n", i);
              ~~     ^
              %ld
1 warning generated.

                    
0.003 s 1 KBi
#13
Incorrecto
                      main.c:30:22: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
      printf("%d\n", i);
              ~~     ^
              %ld
1 warning generated.

                    
0.003 s 1 KBi
#14
Incorrecto
                      main.c:30:22: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
      printf("%d\n", i);
              ~~     ^
              %ld
1 warning generated.

                    
0.071 s 8 KBi
#15
Correcto
                      main.c:30:22: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
      printf("%d\n", i);
              ~~     ^
              %ld
1 warning generated.

                    
0.056 s 9 KBi
#16
Correcto
                      main.c:30:22: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
      printf("%d\n", i);
              ~~     ^
              %ld
1 warning generated.

                    
0.048 s 9 KBi
#17
Incorrecto
                      main.c:30:22: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
      printf("%d\n", i);
              ~~     ^
              %ld
1 warning generated.

                    
0.094 s 9 KBi
#18
Correcto
                      main.c:30:22: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
      printf("%d\n", i);
              ~~     ^
              %ld
1 warning generated.

                    
0.049 s 9 KBi
#19
Incorrecto
                      main.c:30:22: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
      printf("%d\n", i);
              ~~     ^
              %ld
1 warning generated.

                    
0.08 s 9 KBi
#20
Incorrecto
                      main.c:30:22: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
      printf("%d\n", i);
              ~~     ^
              %ld
1 warning generated.

                    
0.056 s 8 KBi
Puntos totales: 55 / 100

Código

/* Code by Eduardo Vega */
#include <stdio.h>
#include <stdlib.h>

int main ()
{
  long size = 0, num = 0, sum_right = 0, sum_left 
  = 0, i;
  long *array = NULL;
  long *arr_aux = NULL;

  scanf("%li", &size);
  array = malloc(sizeof(long int) * size);  
  arr_aux = malloc(sizeof(long int) * size);

  for (i = 0; i < size; i++)
  {
    scanf("%li", &num);    
    array[i] = num;       
    arr_aux[i] = num;    
  }

  for (i = size - 1; i > 0; i--)
      arr_aux[i] += arr_aux[i + 1];

  for(i = 1; i < size; i++)
  {
    if (arr_aux[i] < 0 && arr_aux[i - 1] > 0)
    {
      printf("%d\n", i);
      free(array);
      return 0;
    }
  }

  printf("Impossible\n");
  free(array);
  return 0;
}