Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.005 s | 3 KBi |
#2 |
Correcto
|
0.005 s | 2 KBi |
#3 |
Correcto
|
0.006 s | 2 KBi |
#4 |
Correcto
|
0.006 s | 2 KBi |
#5 |
Correcto
|
0.006 s | 2 KBi |
#6 |
Correcto
|
0.258 s | 4 KBi |
#7 |
Correcto
|
0.238 s | 6 KBi |
#8 |
Correcto
|
0.179 s | 8 KBi |
#9 |
Correcto
|
0.248 s | 5 KBi |
#10 |
Correcto
|
0.185 s | 7 KBi |
#include<bits/stdc++.h> using namespace std; int main(){ int t; scanf(" %d",&t); int cas = 1; while(t--){ int n; scanf(" %d",&n); int ans[n]; memset(ans,-1,sizeof(ans)); vector<pair<int,int>> st; for(int i = 0; i < n;++i){ int val; scanf(" %d",&val); while(st.size() && st.back().second < val){ ans[st.back().first] = val; st.pop_back(); } st.push_back({i,val}); } printf("Case #%d:",cas++); for(int i = 0; i < n;++i) printf(" %d",ans[i]); puts(""); } return 0; }