Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.004 s | 1 KBi |
#2 |
Correcto
|
0.004 s | 1 KBi |
#3 |
Correcto
|
0.005 s | 1 KBi |
#4 |
Correcto
|
0.004 s | 1 KBi |
#5 |
Correcto
|
0.004 s | 1 KBi |
#6 |
Correcto
|
0.227 s | 6 KBi |
#7 |
Correcto
|
0.184 s | 9 KBi |
#8 |
Correcto
|
0.301 s | 6 KBi |
#9 |
Correcto
|
0.216 s | 6 KBi |
#10 |
Correcto
|
0.25 s | 8 KBi |
#include <iostream> #include <list> using namespace std; int main() { int c; cin >> c; for(int j = 0;j<c;j++){ int N; cin >> N; int array[N]; int solve[N]; for(int i = 0;i<N;i++) { cin >> array[i]; } list<int> l; for(int i = N-1;i>=0;i--){ if(l.size() > 0 ){ while(l.size() > 0 && array[i]>=l.front()){ l.pop_front(); } if(l.size() == 0){ solve[i] = -1; l.push_front(array[i]); }else{ solve[i] = l.front(); l.push_front(array[i]); } }else{ solve[i] = -1; l.push_front(array[i]); } } cout << "Case #" << (j+1) << ":"; for(int i = 0;i<N;i++) cout << " " << solve[i]; cout << endl; } return 0; }