Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.005 s | 3 KBi |
#2 |
Correcto
|
0.005 s | 1 KBi |
#3 |
Correcto
|
0.005 s | 5 KBi |
#4 |
Correcto
|
0.005 s | 1 KBi |
#5 |
Correcto
|
0.004 s | 1 KBi |
#6 |
Correcto
|
0.124 s | 7 KBi |
#7 |
Correcto
|
0.108 s | 9 KBi |
#8 |
Correcto
|
0.235 s | 7 KBi |
#9 |
Correcto
|
0.113 s | 8 KBi |
#10 |
Correcto
|
0.18 s | 9 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 response[n]; int response_index[n]; response[n-1] = -1; response_index[n-1] = n-1; for (int i = n - 2; i >= 0; i--) { if (values[i] >= values[i+1]) { bool ok = false; int temp = response_index[i+1]; while(!ok) { if(response[temp] == -1 && values[i] >= values[temp]) { ok = true; response[i] = -1; response_index[i] = i; } else { if (values[i] < values[temp]) { ok = true; response[i] = values[temp]; response_index[i] = temp; } else { temp = response_index[temp]; } } } } else { response[i] = values[i+1]; response_index[i] = i+1; } } cout << "Case #" << k << ": "; for (int i = 0; i < n - 1; i++) { cout << response[i] << " "; } cout << -1 << endl; } return 0; }