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

Envío 6739

Problema 0xcf - Mirando al horizonte

  • Autor: danidiaztech
  • Fecha: 2022-11-13 04:21:30 UTC (Hace más de 1 año)
Caso # Resultado Tiempo Memoria
#1
Incorrecto
0.004 s 4 KBi
#2
Incorrecto
0.005 s 6 KBi
#3
Incorrecto
0.005 s 8 KBi
#4
Incorrecto
0.003 s 6 KBi
#5
Incorrecto
0.004 s 7 KBi
#6
Tiempo límite excedido
1.083 s 7 KBi
#7
Tiempo límite excedido
1.077 s 13 KBi
#8
Tiempo límite excedido
1.076 s 4 KBi
#9
Tiempo límite excedido
1.082 s 5 KBi
#10
Tiempo límite excedido
1.075 s 5 KBi
Puntos totales: 0 / 100

Código

// Made by Daniel Diaz (@Danidiaztech)
#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define forn(i, n) for (int i = 0; i < n; i++) // for in range in python
#define FOR(i, a, b) for (int i = a; i < b; i++) // for in range in python
#define int long long int
#define double long double
#define pb push_back
#define ff first
#define ss second
#define mk make_pair

typedef pair<int, int> pii;

const int MAX = 1e6;
const int MIN = -MAX;
const int INF = LLONG_MAX;
const int MINF = LLONG_MIN;
const int MOD = 1e9 + 7;

// int arr[MAX];
void solve_o2(){
  int n;
  cin >> n;
  int a[n];
  forn(i,n) cin >> a[i];
  // O(n²)
  for (int i = 0; i < n; i++){
    // Look for the next element greater than ai
    bool ok = true;
    for (int j = i + 1; j < n; j++){
      if (a[j] > a[i]){
        ok = false;
        cout << a[j] << " ";
        break;
      }
    }
    if (ok )
      cout << -1 << " ";
  }
  cout << endl;
}

int32_t main() {
  fastInp;
  #if LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif

  int tc = 1;
  cin >> tc;

  for (int t = 1; t <= tc; t++){
    // cout << "Case #" << t << ": ";
    solve_o2();
  }
  return 0;
}