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

Envío 169

Problema 0xcf - Mirando al horizonte

Caso # Resultado Tiempo Memoria
#1
Incorrecto
0.004 s 1 KBi
#2
Incorrecto
0.005 s 1 KBi
#3
Incorrecto
0.005 s 1 KBi
#4
Incorrecto
0.005 s 1 KBi
#5
Incorrecto
0.004 s 1 KBi
#6
Incorrecto
0.084 s 6 KBi
#7
Incorrecto
0.078 s 10 KBi
#8
Incorrecto
0.099 s 6 KBi
#9
Incorrecto
0.08 s 7 KBi
#10
Incorrecto
0.109 s 7 KBi
Puntos totales: 0 / 100

Código

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

/**
 * print_hor - prints the output passed by find_hor function
 * @cant: the number of builtdings
 * @out: the array with the output to print
 *
 * Return: na
*/
void print_hor(int cant, int out[])
{
	while (cant > 0)
	{
		cant--;
		printf("%d ", out[cant]);
	}
	putchar(10);
}

/**
 * find_hor - sets an array with the case of output and
 * call to print_hor function
 *
 * Return: na
*/
void find_hor(void)
{
	int i, j, cant = 0, edif[500000], horiz_edif = 0, out[500000];

	scanf("%d", &cant);

	for (i = cant - 1, j = 0; i >= 0; i--, j++)
	{
		scanf("%d", &edif[j]);
	}

	horiz_edif = edif[cant - 1];
	for (i = cant - 1, j = 0; i >= 0; i--, j++)
	{
		if (edif[i] < horiz_edif)
		{
			out[j] = horiz_edif;
		}
		else
		{
			horiz_edif = edif[i];
			out[j] = -1;
		}
	}

	print_hor(cant, out);
}

/**
 * main - gets the number of cases and call to find_hor function
 *
 * Return: 0
*/
int main(void)
{
	int i, cases = 0;

	scanf("%d", &cases);

	for (i = 0; i < cases; i++)
	{
		printf("case #%d: ", i + 1);
		find_hor();
	}

	return (0);
}