Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.005 s | 1 KBi |
#2 |
Correcto
|
0.005 s | 11 KBi |
#3 |
Correcto
|
0.006 s | 1 KBi |
#4 |
Correcto
|
0.005 s | 9 KBi |
#5 |
Correcto
|
0.007 s | 1 KBi |
#6 |
Correcto
|
0.321 s | 6 KBi |
#7 |
Correcto
|
0.323 s | 5 KBi |
#8 |
Correcto
|
0.376 s | 5 KBi |
#9 |
Correcto
|
0.366 s | 6 KBi |
#10 |
Correcto
|
0.268 s | 14 KBi |
#include <iostream> #include <list> #include <queue> using namespace std; void solveCase() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; ++i) { cin >> a[i]; } list<int> q; vector<int> answer(n); for (int i = n - 1; i >= 0; --i) { while (q.size() > 0 and a[i] >= q.front()) { q.pop_front(); } answer[i] = q.size() == 0 ? -1 : q.front(); q.push_front(a[i]); } for (int i = 0; i < n; ++i) { cout << " " << answer[i]; } cout << endl; } int main() { int N; cin >> N; for (int i = 1; i <= N; ++i) { cout << "Case #" << i << ":"; solveCase(); } }