█████████ ████ ███░░░░░███ ░░███ ███ ░░░ ██████ ███████ ██████ ██████ ░███ ███░░███ ███░░███ ███░░███ ███░░███ ░███ ░███ ░███░███ ░███ ░███████ ░███ ░███ ░░███ ███░███ ░███░███ ░███ ░███░░░ ░███ ░███ ░░█████████ ░░██████ ░░████████░░██████ ░░██████ ░░░░░░░░░ ░░░░░░ ░░░░░░░░ ░░░░░░ ░░░░░░

Envío 2761

Problema 0xcf - Mirando al horizonte

  • Autor: pradomaricon
  • Fecha: 2021-02-04 06:12:51 UTC (Hace alrededor de 3 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.006 s 1 KBi
#2
Correcto
0.007 s 1 KBi
#3
Correcto
0.008 s 2 KBi
#4
Correcto
0.009 s 2 KBi
#5
Correcto
0.007 s 1 KBi
#6
Tiempo límite excedido
1.067 s 7 KBi
#7
Tiempo límite excedido
1.067 s 7 KBi
#8
Tiempo límite excedido
1.085 s 6 KBi
#9
Tiempo límite excedido
1.062 s 7 KBi
#10
Tiempo límite excedido
1.045 s 6 KBi
Puntos totales: 50 / 100

Código

#include <iostream>
#include <vector>

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){
    
    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;
        }
    }
    

}