Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Incorrecto
|
0.004 s | 53 KBi |
#2 |
Incorrecto
|
0.004 s | 15 KBi |
#3 |
Incorrecto
|
0.003 s | 29 KBi |
#4 |
Incorrecto
|
0.006 s | 36 KBi |
#5 |
Incorrecto
|
0.004 s | 70 KBi |
#6 |
Incorrecto
|
0.15 s | 6 KBi |
#7 |
Incorrecto
|
0.16 s | 8 KBi |
#8 |
Incorrecto
|
0.317 s | 7 KBi |
#9 |
Incorrecto
|
0.157 s | 70 KBi |
#10 |
Incorrecto
|
0.24 s | 9 KBi |
#include<bits/stdc++.h> using namespace std; #define el "\n" int main(){ int T; cin>>T; for(int i = 0; i < T; ++i){ int n; cin>>n; vector<int>v; vector<int>ans; stack<int>s; for(int j = 1; j <= n; ++j){ int m; cin>>m; v.push_back(m); } s.push(v[n]); ans.push_back(-1); for(int j = n - 1; j >= 0; --j){ if(s.top() > v[j]){ ans.push_back(s.top()); }else{ ans.push_back(-1); s.pop(); s.push(v[j]); } } for(int j = n ; j > 0; --j){ cout<<ans[j]<<" "; } cout<<el; } return 0; }