Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.005 s | 1 KBi |
#2 |
Correcto
|
0.005 s | 2 KBi |
#3 |
Correcto
|
0.005 s | 1 KBi |
#4 |
Correcto
|
0.006 s | 1 KBi |
#5 |
Correcto
|
0.005 s | 2 KBi |
#6 |
Incorrecto
|
0.474 s | 6 KBi |
#7 |
Correcto
|
0.127 s | 6 KBi |
#8 |
Correcto
|
0.119 s | 6 KBi |
#9 |
Incorrecto
|
0.181 s | 6 KBi |
#10 |
Tiempo límite excedido
|
1.032 s | 3 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; set <int> se; cin>>n; for(int i = 0; i < n; i++) { cin>>a[i]; } int max = 0; for(int i = n-1; i >= 0; i--) { if(a[i] >= max) { max = a[i]; s.push(-1); se.clear(); } else { se.insert(a[i]); //cout<<endl<<"para "<<a[i]<<", se.size()="<<se.size()<<endl; if (se.size() == 1) s.push(max); else { for(int j = a[i]+1; j <= max; j++) { if( se.find(j) != se.end() ) { s.push(j); break; } if( j==max ) { s.push(j); break; } } } } } cout<<"Case #"<<p<<": "; while( !s.empty() ) { cout<<s.top()<<" "; s.pop(); } cout<<endl; } }