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

Envío 620

Problema 0xcf - Mirando al horizonte

  • Autor: orendon
  • Fecha: 2020-09-11 01:45:55 UTC (Hace más de 3 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.007 s 5 KBi
#2
Correcto
0.005 s 57 KBi
#3
Correcto
0.006 s 1 KBi
#4
Correcto
0.006 s 1 KBi
#5
Correcto
0.007 s 1 KBi
#6
Tiempo límite excedido
1.063 s 3 KBi
#7
Tiempo límite excedido
0.33 s 9 KBi
#8
Tiempo límite excedido
0.639 s 4 KBi
#9
Tiempo límite excedido
0.321 s 4 KBi
#10
Tiempo límite excedido
0.594 s 9 KBi
Puntos totales: 50 / 100

Código

// https://codeo.app/problemas/0xcf-mirando-al-horizonte

#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int cases, n, biggerHeight;
    vector<int> buildings;

    cin >> cases;
    for (int c = 1; c <= cases; c++)
    {
        // read buildings heights
        cin >> n;
        buildings = vector<int>(n);
        for (int i = 0; i < n; i++)
        {
            cin >> buildings[i];
        }

        // check for building hidding the horizon
        cout << "Case #" << c << ": ";
        for (int i = 0; i < n; i++)
        {
            biggerHeight = -1;
            for (int j = i + 1; j < n; j++)
            {
                if (buildings[j] > buildings[i])
                {
                    biggerHeight = buildings[j];
                    break;
                }
            }
            cout << biggerHeight << " ";
        }
        cout << endl;
    }

    return 0;
}