Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Incorrecto
|
0.006 s | 2 KBi |
#2 |
Incorrecto
|
0.003 s | 1 KBi |
#3 |
Incorrecto
|
0.007 s | 2 KBi |
#4 |
Incorrecto
|
0.007 s | 2 KBi |
#5 |
Incorrecto
|
0.008 s | 2 KBi |
#6 |
Incorrecto
|
0.185 s | 17 KBi |
#7 |
Incorrecto
|
0.272 s | 6 KBi |
#8 |
Incorrecto
|
0.165 s | 6 KBi |
#9 |
Incorrecto
|
0.35 s | 6 KBi |
#10 |
Incorrecto
|
0.211 s | 8 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; v.push_back(0); 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()); s.push(v[j]); }else{ while(s.size() > 0){ if(s.top() <= v[j] && s.size() == 1){ ans.push_back(-1); s.pop(); s.push(v[j]); break; }else if( s.top() > v[j]){ ans.push_back(s.top()); s.push(v[j]); break; }else{ s.pop(); } } } } cout<<"Case #"<<i + 1<<":"<<" "; for(int j = n ; j > 0; --j){ cout<<ans[j]<<" "; } cout<<el; ans.clear(); v.clear(); } return 0; }