Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.004 s | 1 KBi |
#2 |
Correcto
|
0.005 s | 10 KBi |
#3 |
Correcto
|
0.005 s | 1 KBi |
#4 |
Correcto
|
0.004 s | 1 KBi |
#5 |
Correcto
|
0.003 s | 1 KBi |
#6 |
Correcto
|
0.122 s | 6 KBi |
#7 |
Correcto
|
0.1 s | 8 KBi |
#8 |
Correcto
|
0.111 s | 8 KBi |
#9 |
Correcto
|
0.121 s | 11 KBi |
#10 |
Correcto
|
0.133 s | 8 KBi |
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define ll long long const int maxi = 500100; int a[maxi]; int main(){ ios::sync_with_stdio(0); cin.tie(0); int t; cin>>t; for(int i=1; i<=t; i++){ int n; cin>>n; for(int j=0; j<n; j++){ cin>>a[j]; } stack<int>s; vector<int>ans(n); cout<<"Case #"<<i<<": "; for(int j=0; j<n; j++){ while(!s.empty() && a[j]>a[s.top()]){ ans[s.top()]=a[j]; s.pop(); } s.push(j); } for(auto i: ans){ if(i==0) cout<<-1<<" "; else cout<<i<<" "; } cout<<endl; } }