Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.003 s | 21 KBi |
#2 |
Correcto
|
0.005 s | 1 KBi |
#3 |
Correcto
|
0.004 s | 40 KBi |
#4 |
Correcto
|
0.006 s | 20 KBi |
#5 |
Correcto
|
0.007 s | 21 KBi |
#6 |
Correcto
|
0.273 s | 5 KBi |
#7 |
Correcto
|
0.179 s | 6 KBi |
#8 |
Correcto
|
0.318 s | 6 KBi |
#9 |
Correcto
|
0.239 s | 6 KBi |
#10 |
Correcto
|
0.291 s | 7 KBi |
/// Write by Daniel Perez .PERAPRO #include<bits/stdc++.h> using namespace std; #define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); using vi=vector<int>; #define pb push_back typedef long long ll; int main(){ int T; cin>>T; for(int t=1;t<=T;t++){ int n; cin>>n; vi v(n); for(int i=0;i<n;i++) cin>>v[i]; stack<int> s; s.push(v[n-1]); vi ans(n); ans[n-1]=-1; for(int i=n-2;i>-1;i--){ while(s.size() && v[i]>=s.top()){ s.pop(); } if(s.size()){ ans[i]=s.top(); }else{ ans[i]=-1; } s.push(v[i]); } cout<<"Case #"<<t<<":"; for ( int i=0;i<n;i++) cout<<" "<<ans[i]; cout<<endl; } }