Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Incorrecto
|
0.006 s | 2 KBi |
#2 |
Incorrecto
|
0.005 s | 23 KBi |
#3 |
Incorrecto
|
0.006 s | 1 KBi |
#4 |
Incorrecto
|
0.005 s | 43 KBi |
#5 |
Incorrecto
|
0.005 s | 1 KBi |
#6 |
Incorrecto
|
0.291 s | 6 KBi |
#7 |
Incorrecto
|
0.24 s | 5 KBi |
#8 |
Incorrecto
|
0.285 s | 7 KBi |
#9 |
Incorrecto
|
0.259 s | 7 KBi |
#10 |
Incorrecto
|
0.247 s | 15 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(); } }