Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.005 s | 1 KBi |
#2 |
Correcto
|
0.006 s | 3 KBi |
#3 |
Correcto
|
0.005 s | 2 KBi |
#4 |
Correcto
|
0.006 s | 3 KBi |
#5 |
Correcto
|
0.006 s | 1 KBi |
#6 |
Correcto
|
0.137 s | 6 KBi |
#7 |
Correcto
|
0.137 s | 6 KBi |
#8 |
Correcto
|
0.154 s | 6 KBi |
#9 |
Correcto
|
0.14 s | 6 KBi |
#10 |
Correcto
|
0.147 s | 8 KBi |
#include <iostream> #include <cstring> #include <cstdio> #include <cmath> #include <queue> #include <set> #include <map> #include <vector> #include <stack> #include <algorithm> #define forn(a, n) for(int a = 0; a<(int) (n); ++a) #define rforn(a, n) for(int a = (n)-1; a>=0; --a) using namespace std; const int N = 6e5+20; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int c, n; cin>>c; for(int p = 1; p <= c; p++) { int a [500100]; stack <int> s; stack <int> res; cin>>n; for(int i = 0; i < n; i++) { cin>>a[i]; } for(int i = n-1; i >= 0; i--) { while(!s.empty() && a[i] >= s.top()) { s.pop(); } if (s.size() > 0) res.push(s.top()); else res.push(-1); s.push(a[i]); } cout<<"Case #"<<p<<": "; while( !res.empty() ) { cout<<res.top()<<" "; res.pop(); } cout<<endl; } }