Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Incorrecto
|
0.003 s | 0 KBi |
#2 |
Incorrecto
|
0.005 s | 2 KBi |
#3 |
Correcto
|
0.003 s | 0 KBi |
#4 |
Correcto
|
0.005 s | 42 KBi |
#5 |
Incorrecto
|
0.005 s | 23 KBi |
#6 |
Incorrecto
|
0.133 s | 7 KBi |
#7 |
Correcto
|
0.154 s | 6 KBi |
#8 |
Correcto
|
0.227 s | 8 KBi |
#9 |
Incorrecto
|
0.095 s | 5 KBi |
#10 |
Incorrecto
|
0.12 s | 19 KBi |
#include<bits/stdc++.h> using namespace std; #define el "\n" int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); 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]); } } cout<<"Case #"<<i + 1<<":"<<" "; for(int j = n ; j > 0; --j){ cout<<ans[j]<<" "; } cout<<el; ans.clear(); v.clear(); } return 0; }