Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.006 s | 1 KBi |
#2 |
Incorrecto
|
0.006 s | 1 KBi |
#3 |
Correcto
|
0.005 s | 1 KBi |
#4 |
Correcto
|
0.005 s | 1 KBi |
#5 |
Incorrecto
|
0.007 s | 1 KBi |
#6 |
Incorrecto
|
0.122 s | 6 KBi |
#7 |
Correcto
|
0.119 s | 6 KBi |
#8 |
Correcto
|
0.227 s | 6 KBi |
#9 |
Incorrecto
|
0.126 s | 6 KBi |
#10 |
Incorrecto
|
0.183 s | 7 KBi |
#include <iostream> #include <vector> using namespace std; void print(const vector<int> &a) { for (int i = 0; i < a.size(); i++) { cout << a[i] << " "; } cout << endl; } vector<int> solve(const vector<int> &a) { int maxBuilding = 0; vector<int> solution(a.size()); for (int i = a.size()-1; i >= 0; i--) { if(a[i] >= maxBuilding) { solution[i] = -1; } else { solution[i] = maxBuilding; } maxBuilding = max(maxBuilding, a[i]); } return solution; } int main() { int C; cin >> C; for (int i = 0; i < C; i++) { int N; cin >> N; vector<int> a(N); for (int i = 0; i < N; i++) { cin >> a[i]; } vector<int> s = solve(a); cout << "Case #" << (i+1) << ": "; print(s); } return 0; }