Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.006 s | 1 KBi |
#2 |
Correcto
|
0.006 s | 10 KBi |
#3 |
Correcto
|
0.006 s | 2 KBi |
#4 |
Correcto
|
0.006 s | 6 KBi |
#5 |
Correcto
|
0.007 s | 1 KBi |
#6 |
Correcto
|
0.104 s | 6 KBi |
#7 |
Correcto
|
0.133 s | 6 KBi |
#8 |
Correcto
|
0.112 s | 6 KBi |
#9 |
Correcto
|
0.108 s | 6 KBi |
#10 |
Correcto
|
0.122 s | 8 KBi |
/// Write by Daniel Perez .PERAPRO #include<bits/stdc++.h> using namespace std; #define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); using vi=vector<int>; #define pb push_back typedef long long ll; int main(){ fast_io; int testcases; cin>>testcases; int t=testcases; while(testcases--){ cout<<"Case #"<<abs(t-testcases)<<":"; int n; cin>>n; vector<int> a(n); for(int i=0;i<n;i++) cin>>a[i]; vector<int> ans(n); for(int i=n-1;i>-1;i--){ ans[i]=i+1; if(i!=n-1 && a[ans[i]]<=a[i]){ while(ans[i]<n && a[ans[i]]<=a[i]){ ans[i]=ans[ans[i]]; } } } //for(auto x:ans) cout<<" "<<x; //cout<<endl; for(int i=0;i<n;i++){ if(ans[i]>=n) cout<<" "<<-1; else cout<<" "<<a[ans[i]]; } cout<<endl; } }