Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.005 s | 1 KBi |
#2 |
Correcto
|
0.005 s | 6 KBi |
#3 |
Correcto
|
0.004 s | 1 KBi |
#4 |
Correcto
|
0.005 s | 4 KBi |
#5 |
Correcto
|
0.005 s | 20 KBi |
#6 |
Correcto
|
0.084 s | 6 KBi |
#7 |
Correcto
|
0.072 s | 5 KBi |
#8 |
Correcto
|
0.091 s | 5 KBi |
#9 |
Tiempo límite excedido
|
0.833 s | 3 KBi |
#10 |
Tiempo límite excedido
|
1.003 s | 3 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{ for(int x=j; x<=n; x++){ if(a[x]>a[j]){ ans[j]=a[x]; break; } } } } cout<<"Case #"<<i<<": "; for(int j=1; j<=n; j++){ cout<<ans[j]<<" "; } cout<<endl; } }