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

Envío 1468

Problema 0xcf - Mirando al horizonte

  • Autor: Serivt
  • Fecha: 2020-10-28 01:03:36 UTC (Hace más de 3 años)
Caso # Resultado Tiempo Memoria
#1
Error en tiempo de ejecución (NZEC)
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.005 s 6 KBi
#2
Error en tiempo de ejecución (NZEC)
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.005 s 1 KBi
#3
Error en tiempo de ejecución (NZEC)
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.005 s 1 KBi
#4
Error en tiempo de ejecución (NZEC)
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.006 s 2 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.006 s 14 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.005 s 1 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.005 s 1 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.005 s 1 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.005 s 1 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.006 s 1 KBi
Puntos totales: 0 / 100

Código

#include <iostream>
#include <vector>
using namespace std;

void solve() {
	int n;
	vector<int> a(n);
	vector<int> answer(n);
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
    }
    for (int i = n - 1; i >= 0; i--) {
    	int max_a = -1;
    	for (int j = i; j < n; j++) {
    		if (a[j] > a[i]) {
    			max_a = a[j];
    			break;
    		}
    	}
    	answer[i] = max_a;
    }
    for (int i = 0; i < n; ++i) {
	    cout << " " << answer[i];
    }
    cout << endl;
}

int main() {
	int cases;
	cin >> cases;
	for (int c = 1; c <= cases; c++) {
		cout << "Case #" << c << ":";
		solve();
	}
}