Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.004 s | 1 KBi |
#2 |
Correcto
|
0.004 s | 2 KBi |
#3 |
Correcto
|
0.006 s | 2 KBi |
#4 |
Correcto
|
0.005 s | 2 KBi |
#5 |
Correcto
|
0.006 s | 1 KBi |
#6 |
Correcto
|
0.177 s | 7 KBi |
#7 |
Correcto
|
0.096 s | 6 KBi |
#8 |
Correcto
|
0.137 s | 6 KBi |
#9 |
Correcto
|
0.154 s | 6 KBi |
#10 |
Correcto
|
0.107 s | 8 KBi |
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define ll long long #define sz(x) int(x.size()) #define dbg(x) cout << #x << " = " << x << endl int main() { ios_base::sync_with_stdio(false); cin.tie(0); int t; cin >> t; int ts = 1; while (t--) { int n; cin >> n; int val[n]; for (int &i: val) cin >> i; int ans[n]; memset(ans, -1, sizeof ans); stack<int> st; for (int i = n - 1; i >= 0; --i) { while (sz(st) && val[i] >= st.top()) { st.pop(); } ans[i] = sz(st) ? st.top(): -1; st.push(val[i]); } cout << "Case #" << ts++ << ":"; for (int &i: ans) cout << " " << i; cout << endl; } return 0; }