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

Envío 1132

Problema 0xcf - Mirando al horizonte

  • Autor: juantamayo26
  • Fecha: 2020-10-11 00:58:10 UTC (Hace más de 3 años)
Caso # Resultado Tiempo Memoria
#1
Incorrecto
0.006 s 1 KBi
#2
Incorrecto
0.005 s 1 KBi
#3
Incorrecto
0.004 s 1 KBi
#4
Incorrecto
0.006 s 1 KBi
#5
Incorrecto
0.006 s 1 KBi
#6
Incorrecto
0.089 s 6 KBi
#7
Incorrecto
0.083 s 5 KBi
#8
Error en tiempo de ejecución (NZEC)
Exited with error status 153
run: line 1:     3 File size limit exceeded(core dumped) ./a.out
0.102 s 8 KBi
#9
Incorrecto
0.074 s 6 KBi
#10
Incorrecto
0.082 s 7 KBi
Puntos totales: 0 / 100

Código

#include <iostream>

using namespace std;

#define endl '\n'
#define ll long long
int a[500100];
int ans[500100];

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=1; i<=n; i++){
      cin>>a[i];
    }
    int aux=a[n];
    ans[n] = -1;
    int aux2;
    int maxi = a[n];
    for(int i=n-1; i>0; i--){
      maxi = max(maxi, a[i]);
      aux2=a[i];
      if(aux<=a[i]&&aux>=maxi){
        ans[i]=-1;
        aux=a[i];
      }else{
        ans[i]=maxi;
      }
      if(aux>=a[i]){
        ans[i]=aux;
      }
      if(a[i-1]<aux2){
        aux=a[i];
      }
    }
    cout<<"Case #"<<j<<": ";
    for(int i=1; i<=n; i++){
      cout<<ans[i]<<" ";
    }
    cout<<endl;
  }
}