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

Envío 1122

Problema 0xcf - Mirando al horizonte

  • Autor: yerminson
  • Fecha: 2020-10-10 23:08:23 UTC (Hace más de 3 años)
Caso # Resultado Tiempo Memoria
#1
Incorrecto
0.005 s 14 KBi
#2
Correcto
0.005 s 32 KBi
#3
Correcto
0.006 s 10 KBi
#4
Correcto
0.006 s 6 KBi
#5
Incorrecto
0.005 s 6 KBi
#6
Tiempo límite excedido
1.067 s 4 KBi
#7
Tiempo límite excedido
0.759 s 3 KBi
#8
Correcto
0.223 s 6 KBi
#9
Tiempo límite excedido
0.579 s 3 KBi
#10
Tiempo límite excedido
1.061 s 3 KBi
Puntos totales: 40 / 100

Código

#include <iostream>
using namespace std;

int main() {

  int c;
  cin >> c;

  for (int k = 1; k <= c; k++) {
    int n;
    cin >> n;
    int values[n];

    for (int i = 0; i < n; i++) {
      cin >> values[i];
    }
    
    int response[n];
    response[n-1] = -1;
    
    for (int i = n - 2; i >= 0; i--) {
        if (values[i] >= values[i+1]) {
            bool ok = false;
            
            int temp = i+1;
            while(!ok) {
                if(response[temp] == -1 && values[i] > values[temp]) {
                    ok = true;
                    response[i] = -1;
                }
                else {
                    if (values[i] < values[temp]) {
                       ok = true;
                       response[i] = values[temp];
                    }
                    else {
                        temp+=1;
                    }
                }
            }
        }
        else
        {
            response[i] = values[i+1];
        }
     
    }

    cout << "Case #" << k << ": ";
    for (int i = 0; i < n - 1; i++)
    {
      cout << response[i] << " ";
    }

    cout << -1 << endl;
  }

  return 0;
}