Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.006 s | 1 KBi |
#2 |
Incorrecto
|
0.005 s | 1 KBi |
#3 |
Correcto
|
0.005 s | 1 KBi |
#4 |
Correcto
|
0.007 s | 1 KBi |
#5 |
Correcto
|
0.005 s | 1 KBi |
#6 |
Incorrecto
|
0.073 s | 9 KBi |
#7 |
Correcto
|
0.073 s | 8 KBi |
#8 |
Correcto
|
0.094 s | 6 KBi |
#9 |
Incorrecto
|
0.07 s | 6 KBi |
#10 |
Incorrecto
|
0.106 s | 7 KBi |
#include <iostream> using namespace std; #define endl '\n' #define ll long long const int maxi = 500100; int a[maxi]; int ans[maxi]; int main(){ ios::sync_with_stdio(0); cin.tie(0); int t; cin>>t; for(int i=1; i<=t; i++){ int n; cin>>n; for(int j=1; j<=n; j++){ cin>>a[j]; } int aux = a[n]; ans[n]=-1; int maxi = a[n]; for(int j=n-1; j>0; j--){ maxi = max(a[j], maxi); if(a[j]<a[j+1]){ aux=a[j+1]; } if(a[j]>=aux && a[j]==maxi){ ans[j]=-1; aux=a[j]; }else if(a[j]<aux){ ans[j]=aux; } else ans[j]=maxi; } cout<<"Case #"<<i<<": "; for(int j=1; j<=n; j++){ cout<<ans[j]<<" "; } cout<<endl; } }