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

Envío 1257

Problema 0xcf - Mirando al horizonte

  • Autor: EduardoVega
  • Fecha: 2020-10-13 05:47:40 UTC (Hace alrededor de 4 años)
Caso # Resultado Tiempo Memoria
#1
Incorrecto
                      main.c:34:26: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
    printf("Case #%d: ", i + 1);
                  ~~     ^~~~~
                  %ld
main.c:36:23: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
        printf("%d ", edificios[j]);
                ~~    ^~~~~~~~~~~~
                %ld
2 warnings generated.

                    
0.004 s 7 KBi
#2
Incorrecto
                      main.c:34:26: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
    printf("Case #%d: ", i + 1);
                  ~~     ^~~~~
                  %ld
main.c:36:23: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
        printf("%d ", edificios[j]);
                ~~    ^~~~~~~~~~~~
                %ld
2 warnings generated.

                    
0.004 s 2 KBi
#3
Incorrecto
                      main.c:34:26: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
    printf("Case #%d: ", i + 1);
                  ~~     ^~~~~
                  %ld
main.c:36:23: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
        printf("%d ", edificios[j]);
                ~~    ^~~~~~~~~~~~
                %ld
2 warnings generated.

                    
0.002 s 1 KBi
#4
Incorrecto
                      main.c:34:26: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
    printf("Case #%d: ", i + 1);
                  ~~     ^~~~~
                  %ld
main.c:36:23: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
        printf("%d ", edificios[j]);
                ~~    ^~~~~~~~~~~~
                %ld
2 warnings generated.

                    
0.002 s 1 KBi
#5
Error en tiempo de ejecución (NZEC)
                      main.c:34:26: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
    printf("Case #%d: ", i + 1);
                  ~~     ^~~~~
                  %ld
main.c:36:23: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
        printf("%d ", edificios[j]);
                ~~    ^~~~~~~~~~~~
                %ld
2 warnings generated.

                    
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.005 s 1 KBi
#6
Incorrecto
                      main.c:34:26: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
    printf("Case #%d: ", i + 1);
                  ~~     ^~~~~
                  %ld
main.c:36:23: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
        printf("%d ", edificios[j]);
                ~~    ^~~~~~~~~~~~
                %ld
2 warnings generated.

                    
0.079 s 14 KBi
#7
Incorrecto
                      main.c:34:26: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
    printf("Case #%d: ", i + 1);
                  ~~     ^~~~~
                  %ld
main.c:36:23: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
        printf("%d ", edificios[j]);
                ~~    ^~~~~~~~~~~~
                %ld
2 warnings generated.

                    
0.07 s 5 KBi
#8
Correcto
                      main.c:34:26: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
    printf("Case #%d: ", i + 1);
                  ~~     ^~~~~
                  %ld
main.c:36:23: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
        printf("%d ", edificios[j]);
                ~~    ^~~~~~~~~~~~
                %ld
2 warnings generated.

                    
0.095 s 6 KBi
#9
Incorrecto
                      main.c:34:26: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
    printf("Case #%d: ", i + 1);
                  ~~     ^~~~~
                  %ld
main.c:36:23: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
        printf("%d ", edificios[j]);
                ~~    ^~~~~~~~~~~~
                %ld
2 warnings generated.

                    
0.08 s 6 KBi
#10
Incorrecto
                      main.c:34:26: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
    printf("Case #%d: ", i + 1);
                  ~~     ^~~~~
                  %ld
main.c:36:23: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
        printf("%d ", edificios[j]);
                ~~    ^~~~~~~~~~~~
                %ld
2 warnings generated.

                    
0.083 s 6 KBi
Puntos totales: 10 / 100

Código

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

int main ()
{
  long int casos = 0, num_edificios = 0, altura = 
  0, mayor = 0, i, j;
  long int *edificios = NULL;

  scanf("%li", &casos);
  for (i = 0; i < casos; i++)
  {
    scanf("%li", &num_edificios);
    edificios = malloc(sizeof(long int) * 
    num_edificios);

    for (j = 0; j < num_edificios; j++)
    {
      scanf("%li", &altura);
      edificios[i] = altura;
    }
    
    for (j = num_edificios - 1; j >= 0; j--)
    {      
      if (edificios[j] >= mayor)
      {
        mayor = edificios[j];
        edificios[j] = -1;
      }          
      else
          edificios[j] = mayor;
    }
   
    printf("Case #%d: ", i + 1);
    for (j = 0; j < num_edificios; j++)
        printf("%d ", edificios[j]);

    putchar('\n');
    mayor = 0;
    free(edificios);
  }
  return 0;
}