Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.005 s | 3 KBi |
#2 |
Correcto
|
0.007 s | 4 KBi |
#3 |
Incorrecto
|
0.005 s | 1 KBi |
#4 |
Correcto
|
0.005 s | 2 KBi |
#5 |
Correcto
|
0.006 s | 2 KBi |
#6 |
Incorrecto
|
0.143 s | 6 KBi |
#7 |
Incorrecto
|
0.107 s | 7 KBi |
#8 |
Tiempo límite excedido
|
1.027 s | 6 KBi |
#9 |
Incorrecto
|
0.125 s | 19 KBi |
#10 |
Tiempo límite excedido
|
1.096 s | 4 KBi |
#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 current = 0; int response[n]; for (int i = n - 1; i >= 0; i--) { if (values[i] >= current) { int temp = -1; bool valid = true; for (int h = i + 1; h < n && valid; h++) { int comp = 0; if (response[h] == -1) { comp = values[h]; } else { comp = response[h]; } if (values[i] <= comp) { temp = response[h]; valid = false; } } response[i] = temp; } else { response[i] = current; } current = values[i]; } cout << "Case #" << k << ": "; for (int i = 0; i < n - 1; i++) { cout << response[i] << " "; } cout << -1 << endl; } return 0; }