Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.005 s | 1 KBi |
#2 |
Correcto
|
0.006 s | 1 KBi |
#3 |
Correcto
|
0.007 s | 2 KBi |
#4 |
Correcto
|
0.006 s | 10 KBi |
#5 |
Correcto
|
0.006 s | 54 KBi |
#6 |
Correcto
|
0.236 s | 6 KBi |
#7 |
Correcto
|
0.216 s | 5 KBi |
#8 |
Correcto
|
0.298 s | 6 KBi |
#9 |
Correcto
|
0.236 s | 5 KBi |
#10 |
Correcto
|
0.347 s | 7 KBi |
#include <iostream> #include <list> 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]; list <int> q; for (int i = n - 1; i >= 0; i--) { while (q.size() > 0 && values[i] >= q.front()) { q.pop_front(); } response[i] = q.size() == 0 ? -1 : q.front(); q.push_front(values[i]); } cout << "Case #" << k << ": "; for (int i = 0; i < n - 1; i++) { cout << response[i] << " "; } cout << -1 << endl; } return 0; }