Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.005 s | 2 KBi |
#2 |
Incorrecto
|
0.005 s | 6 KBi |
#3 |
Correcto
|
0.005 s | 1 KBi |
#4 |
Correcto
|
0.005 s | 2 KBi |
#5 |
Incorrecto
|
0.005 s | 3 KBi |
#6 |
Incorrecto
|
0.259 s | 6 KBi |
#7 |
Correcto
|
0.253 s | 5 KBi |
#8 |
Correcto
|
0.411 s | 6 KBi |
#9 |
Incorrecto
|
0.202 s | 12 KBi |
#10 |
Incorrecto
|
0.354 s | 9 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]; } queue<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(); } answer[i] = q.size() == 0 ? -1 : q.front(); q.push(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(); } }