Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.007 s | 1 KBi |
#2 |
Correcto
|
0.005 s | 2 KBi |
#3 |
Correcto
|
0.006 s | 1 KBi |
#4 |
Correcto
|
0.007 s | 2 KBi |
#5 |
Correcto
|
0.006 s | 1 KBi |
#6 |
Error en tiempo de ejecución (NZEC)
Exited with error status 139 run: line 1: 3 Segmentation fault (core dumped) ./a.out |
0.02 s | 3 KBi |
#7 |
Error en tiempo de ejecución (NZEC)
Exited with error status 139 run: line 1: 3 Segmentation fault (core dumped) ./a.out |
0.041 s | 3 KBi |
#8 |
Error en tiempo de ejecución (NZEC)
Exited with error status 139 run: line 1: 3 Segmentation fault (core dumped) ./a.out |
0.031 s | 4 KBi |
#9 |
Error en tiempo de ejecución (NZEC)
Exited with error status 139 run: line 1: 3 Segmentation fault (core dumped) ./a.out |
0.03 s | 3 KBi |
#10 |
Error en tiempo de ejecución (NZEC)
Exited with error status 139 run: line 1: 3 Segmentation fault (core dumped) ./a.out |
0.027 s | 4 KBi |
#include <iostream> #include <vector> #include <stack> using namespace std; #define ll long long const int maxi = 5000; vector<int>a(maxi); int main(){ ios::sync_with_stdio(0); cin.tie(0); int t; cin>>t; for(int j=1; j<=t; j++){ int n; cin>>n; for(int i =0; i<n ;i++){ cin>>a[i]; } stack<int>s; vector<int>ans(n+1); for(int i =0; i<n ;i++){ while(s.size() && (a[i] > a[s.top()])){ ans[s.top()] = a[i]; s.pop(); } s.push(i); } while(s.size()){ s.pop(); } for(int i =0; i<n ;i++){ if(ans[i] == 0){ ans[i] = -1; } } cout<<"Case #"<<j<<": "; for(int i =0; i<n ;i++){ cout<<ans[i]<<" "; } cout<<endl; } return 0; }