Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Incorrecto
|
0.007 s | 1 KBi |
#2 |
Incorrecto
|
0.007 s | 2 KBi |
#3 |
Incorrecto
|
0.007 s | 2 KBi |
#4 |
Incorrecto
|
0.005 s | 1 KBi |
#5 |
Error en tiempo de ejecución (NZEC)
Exited with error status 139 run: line 1: 3 Segmentation fault (core dumped) ./a.out |
0.007 s | 1 KBi |
#6 |
Incorrecto
|
0.234 s | 6 KBi |
#7 |
Incorrecto
|
0.21 s | 6 KBi |
#8 |
Incorrecto
|
0.369 s | 6 KBi |
#9 |
Incorrecto
|
0.165 s | 7 KBi |
#10 |
Incorrecto
|
0.211 s | 7 KBi |
#include <iostream> #include <vector> #include <stack> using namespace std; void horizontes(int length,vector<int> a,vector<int> &soluc); int main(){ int numCases; cin >> numCases; for(int i=0;i<numCases;++i){ int length; cin >> length; vector<int> a(length); vector<int> soluc(length); for(int j=0;j<length;j++){ cin >> a[j]; } horizontes(length,a,soluc); //printar cout << "Case #"<< i + 1 << ": "; for(int j=0;j<length;j++){ cout << soluc[j] << " "; } cout << "\n"; } } void horizontes(int length,vector<int> a, vector<int> &soluc){ stack<int> blockers; for(int k=length-1;k==0;k--){ while(!blockers.empty() && a[k]>=blockers.top()){ blockers.pop(); } if (!blockers.empty()){ soluc[k]=-1; }else{ soluc[k]= blockers.top(); } blockers.push(a[k]); } // for(int k =0;k<length;k++){ // bool blocked = false; // int j = k+1; // while(!blocked && j<length+1){ // if(a[j]>a[k]){ // blocked = true; // soluc[k]=a[j]; // } // j++; // } // if(j==length+1){ // soluc[k]=-1; // } // } }